You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP网页端无法上传120M以上大文件问题求助

Fixing Large File Upload Issues in PHP (AJAX)

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 than upload_max_filesize—for 120MB+ files, try:

    post_max_size = 200M
    
  • max_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 minutes
    
  • memory_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 = 256M
    
  • max_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 your max_input_time setting:

    max_execution_time = 300
    
  • upload_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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:28:46