【发布时间】:2011-11-11 20:22:15
【问题描述】:
我有一个表格:
<form method="post" action="includes/tagcreate.php">
<input type="file" name="image" />
<input class="btn btn-orange" name="submit" type="submit" value="Create" />
</form>
还有tagcreate.php:
require('connection.php');
if (isset($_POST["submit"])) {
$image = $_POST['image'];
$userfile_name = $_FILES["image"]["name"];
$large_image_location = '../';
$query = "INSERT INTO tags (image) VALUES ('{$image}')";
if (isset($_FILES["image"]["name"])){
move_uploaded_file($userfile_name, $large_image_location);
chmod ($large_image_location, 0777);
}
if (mysql_query($query, $connection)) {
header("location: ../");
exit;
} else {
echo "<p>Failed to add:</p>";
echo "<p>" . mysql_error() . "</p>";
}
}
所以数据库查询工作正常但是...没有文件。我之前没有真正处理过上传,所以我觉得我可能在这里遗漏了一些相当明显的东西。
【问题讨论】: