嗨,我正在尝试创建一个表单,它将按照一些web示例加载图像,但是我无法加载这些图像。我在用apache做我的私人软呢帽盒。是否有一些设置需要我对Apache进行不同的处理?下面是应该上传图像的表单脚本:
<form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "get">
<table>
<tr>
<th>Title:</th> <td><input type="text" name ="photoname"></td>
</tr>
<tr>
<th>Photograph:</th> <td><input type="file" id="file" name="file" accept="image/*"></td>
</tr>
<tr>
<th>Photographer:</th><td><input type="" name="photographer"></td>
</tr>
<tr>
<th>Genre:</th><td><input type = "" name="genre"></td>
</tr>
<table>
<input type="submit" value = "Submit">
</form>下面是我的PHP脚本:
<?php
$uploaddir = '/var/www/html/photodb';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['file']['name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>当我通过表单添加图像时,php表单会失败,上面写着“可能的文件上传攻击!”我想这意味着要么文件无法移动,要么文件没有上传?
我这样做是为了我的大学作业,任何回应或其他想法都是非常感谢的:)。
发布于 2013-08-24 18:54:56
将方法更改为POST:
<form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "post">您不能通过GET方法发布文件。
发布于 2013-08-24 18:54:43
你为什么不用表格帖呢?
<form name ="input" enctype="multipart/form-data" action = "addPhotograph.php" method = "post">https://stackoverflow.com/questions/18421977
复制相似问题