簡體   English   中英

在本地主機上上傳圖像時獲取UPLOAD_ERR_PARTIAL

[英]Getting UPLOAD_ERR_PARTIAL when uploading images on localhost

我正在使用一個簡單的html表單上載圖像,然后將其保存在本地主機上的目錄中。

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" enctype="multipart/form-data" method="post">
<label for="img">Pick a picture</label>
<input id="img" type="file" name="image">
<input type="submit" name="imageProfil" value="Upload the image">
</form>

但是,當我處理圖像時,在檢查錯誤(在$ _FILES ['image'] ['errors']中時,出現錯誤3,這意味着文件僅部分上傳了)。

此外,每次我上傳文件時,在第一個響應之后(在我身上引發異常),我都不會得到任何響應。 我已經完成了所有錯誤檢查,確實將enctype =“ multipart / form-data”放在了表單上,而我在這里基本上一無所知。

感謝您的時間。

您必須在php.ini文件中檢查您的PHP配置。 如果您的上傳不斷被中斷,則您需要增加最大上傳大小或增加PHP腳本超時的時間。 檢查以下變量:

post_max_size
upload_max_filesize
max_execution_time

您可以使用ini_set函數增加PHP配置文件或增加腳本。 有關更多詳細信息,請查閱手冊。 PHP手冊

我也收到UPLOAD_ERR_PARTIAL錯誤,並且正確設置了變量post_max_sizeupload_max_filesizemax_execution_time 然后,我嘗試按照Kirogo的建議 上傳一個非常小的文件 (2字節),並且收到以下警告:

Warning: move_uploaded_file(files/myfile.txt): failed to open stream: Permission denied [...]
Warning: move_uploaded_file(): Unable to move '/tmp/phps8Jdwt' to 'files/myfile.txt' [...]

修復服務器上的文件/目錄權限后,上載再次起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM