我無法成功上傳圖像/文件到我的服務器。 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'], $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>
窺探到web服務器日誌。你不能用盡最大上傳大小嗎? – spacediver 2012-08-02 21:03:36
上傳文件夾是否具有寫入文件的適當權限? – j08691 2012-08-02 21:04:52
位於imageController.php的頂部。把'print_r($ _ FILES); print_r($ _ POST); exit()' – 2012-08-02 21:06:06