1
所以這個語法連接並獲取信息發佈到數據庫,但我無法弄清楚如何獲取圖像的網址發佈到數據庫。無論我改變test1它不會發布。獲取圖片的URL後上傳
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;
}
我已經把它改成如下---的mysql_query( 「INSERT INTO帖(帖子ID,POST_CONTENT)VALUES( 'NULL'「,」 $。 upload_url。「')」); ---這只是一個空行。我需要它爲我提供http://格式圖片的路徑。 – CodingNoob
如果id是AUTO_INCREMENT let postid away.mysql_query(「INSERT INTO posts(post_content) VALUES('test1')」); –
當然,我可以拿出來,但我的問題是我如何得到它發佈的網址。 – CodingNoob