PHP网页端无法上传120M以上大文件问题求助
Hey there, let's tackle those frustrating partial uploads and progress bar resets you're facing. Since you've already adjusted some php.ini settings, here are the critical ones you might have missed—each tied directly to the symptoms you described:
Key php.ini Settings to Adjust
post_max_size
This controls the total size of all data sent in a POST request (your file + any accompanying form fields). The reason regular files fail halfway while images succeed is likely because the combined size of the file and form data hits this limit.
Set it to a value larger thanupload_max_filesize—for 120MB+ files, try:post_max_size = 200Mmax_input_time
Uploading large files takes time, and the default limit (often 30 seconds) can trigger a timeout mid-upload, causing your progress bar to reset.
Increase it to give enough transfer time. For 120MB files (accounting for average upload speeds), try:max_input_time = 300 ; 5 minutesmemory_limit
Regular files might require more memory to process during upload compared to optimized images. If your script hits memory limits handling non-image files, it will terminate the upload prematurely.
Set this to a value greater than your maximum file size:memory_limit = 256Mmax_execution_time
While this affects script runtime after upload completes, if your backend processes the file immediately (e.g., moving, validating), a short execution time could cause failures. Match it to yourmax_input_timesetting:max_execution_time = 300upload_tmp_dir
Double-check that this directory exists, has read/write permissions for your web server user, and has enough free space. If the temp folder is full or inaccessible, uploads will fail mid-transfer. Set it explicitly if needed:upload_tmp_dir = "/path/to/writable/tmp/folder"session.gc_maxlifetime
If your AJAX upload relies on sessions (e.g., for authentication), a short session timeout can kill the request before upload finishes. Extend it to cover the expected upload duration:session.gc_maxlifetime = 1800 ; 30 minutes
Important Final Step
After updating these settings, restart your web server (Apache/Nginx) and PHP-FPM—changes to php.ini won’t take effect until you do this.
A quick note on why images succeed: They’re often compressed, so their actual transfer size is smaller than the file size you see, or your backend handles them with more memory-efficient processes compared to regular files.
内容的提问来源于stack exchange,提问作者Bhuvan Gandhi

