1

したがって、この構文は接続してデータベースに投稿された情報を取得しますが、データベースに投稿する画像の URL を取得する方法がわかりません。test1 を変更しても投稿されません。

protected function trim_file_name($name, $type, $index) {
    // Remove path information and dots around the filename, to prevent uploading
    // into different directories or replacing hidden system files.
    // Also remove control characters and spaces (\x00..\x20) around the filename:
    $file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
    // Add missing file extension for known image types:
    if (strpos($file_name, '.') === false &&
        preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
        $file_name .= '.'.$matches[1];
    }
    if ($this->options['discard_aborted_uploads']) {
        while(is_file($this->options['upload_dir'].$file_name)) {
            $file_name = $this->upcount_name($file_name);
        }
    }
    $con = mysql_connect("localhost","-----","-----");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("-----", $con);

    mysql_query("INSERT INTO posts (postid, post_content)
    VALUES ('', 'test1')");

    mysql_close($con);
    {
    header("Location: http://snarb.com/index.php");
    }
    return $file_name;

}
4

1 に答える 1

0

mysql_query 行を次のように変更します。

 mysql_query("INSERT INTO posts (post_content) VALUES ('" . mysql_real_escape_string($file_name) . "')");
于 2013-03-24T18:53:08.927 に答える