我无法将图像/文件成功上传到我的服务器。 php如下:
//This is the directory where images will be saved
$uploadDir = "./";
$uploadFile = $uploadDir . basename( $_FILES['photo']['name']);
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $uploadFile)){
echo "The file has been uploaded successfully.";
} else {
print_r($_FILES);
}
我选择了此脚本所在的目录,以确保在上传到最终目录之前的功能。我想上传照片,稍后会检查文件扩展名 - 但是现在我至少需要上传功能才能正常工作。
我返回一个空数组。
表格如下:
<form id="imageUploadForm" name="imageForm" enctype="multipart/form-data" action="imageController.php">
<label for="photo" class="blogLabel">Upload an Image</label>
<input type="file" name="photo" id="imageUpload">
<input type="submit" name="submit" id="imageSubmit" class="btn btn-primary" value="Upload">
</form>
答案 0 :(得分:0)
你忘记了表格最重要的事情 - method
!
如果没有设置方法,则默认为get
。
你想要post
!
将method="post"
添加到表单中。