通过返回空数组的PHP上传图像

通过返回空数组的PHP上传图像,php,Php,我无法成功地将图像/文件上载到我的服务器。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'],

我无法成功地将图像/文件上载到我的服务器。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>
我选择了这个脚本所在的目录,以确保在上传到最终目录之前的功能。我想上传照片,稍后会检查文件扩展名-但现在我至少需要上传功能才能工作

返回一个空数组

表格如下:

//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>

上传图像

您忘记了表单最重要的一点--
方法

如果没有方法设置,则默认为
get

你想要
post


method=“post”
添加到表单中。

查看Web服务器日志。你不能用完最大上传大小吗?上传文件夹有写文件的权限吗?我忘了把
method=“POST”
Doh@不要再把你的行动改成全新的问题了……把形式的方法,即method=“post”@Dagon ha!我一直在想念那些新的评论,哈哈。这里发生了什么。。。我的网速太慢了。。。。