【发布时间】:2017-10-10 17:43:38
【问题描述】:
我有一个 html 表单(用于博客文章),我想将所有内容保存在数据库表中。它工作正常,但是当我为图像添加一列时,它也可以以相同的 html 表单上传,然后它没有保存任何东西。
代码如下:
$imagepath = 'https://myurl.com/uploads/' . $_FILES['image']['name'];
$db = new PDO($dsn, $dbuser, $dbpass);
$query = $db->prepare(
"INSERT INTO posts (author, title, text, date, image)
VALUES(:author, :title, :text, NOW()), '$imagepath'");
$query->execute(array("author" => $author, "title" => $title, "text" => $text));
$db = null;
【问题讨论】: