File upload-php upload large file (above 100M)

Source: Internet
Author: User
PHP How to upload large files, configuration as if the maximum set to 8M, I would like to know how to upload a hundreds of m file (do not use specialized client software), it seems to be a shard What, do you know how to do it?

Reply content:

PHP How to upload large files, configuration as if the maximum set to 8M, I would like to know how to upload a hundreds of m file (do not use specialized client software), it seems to be a shard What, do you know how to do it?

Server-side Apache/nginx is a support for the continuation of the breakpoint, client curl is also supporting the continuation of the breakpoint.
Browser default support download breakpoint continuation, you can use Jquery-file-upload to achieve block upload and breakpoint continuation, the server is implemented in PHP to receive.
Https://github.com/blueimp/jQuery-File-Upload/wiki/Chunked-file-uploads#resuming-file-uploads
https://github.com/blueimp/jQuery-File-Upload/blob/master/server/php/UploadHandler.php
In order to avoid large file uploads blocking PHP services, you can open a separate PHP-FPM process pool for uploading, leveraging the isolation of the pool provided by PHP-FPM, separating compute dense and I/O intensive (upload) operations to reduce the impact of blocking on the entire PHP application.

Follow-up additional notes:

info.php
  
               
  
           PHP文件上传测试                
  
               

Nginx and PHP-FPM work processes are only open 1.
Upload images in 2KB per second:

time trickle -s -u 2 curl \-F "action=info.php" \-F "upload_file=@linux.jpeg;type=image/jpeg" \-F "submit=提交" \http://www.example.com/app/info.phpsudo netstat -antp|egrep "curl|nginx|fpm"

It is found that only nginx and curl are in the established state, and Nginx and FPM are not blocked.

top -p 4075 可见Nginx单线程.sudo strace -p 4075 可见Nginx调用recvfrom接收数据并且pwrite保存数据.sudo strace -p 13751 可见PHP-FPM是在Nginx接收完成用户上传的数据时才获取数据.

That being the case, the other open FPM process pool that I envisioned is not very useful for uploading operations. PHP-FPM is not blocked during file upload, because Nginx receives the uploaded content and then gives it to PHP-FPM.
Attached: Download images in 2KB per second

time trickle -s -d 2 \wget http://www.example.com/app/uploads/linux.jpeg -O /dev/null

Using third-party breakpoint continuation controls (ActiveX controls)

such as XPROER.HTTPUPLOADER5, similar to the large attachment QQ mailbox

or using swfupload, it is said that the maximum support is around 2G

PHP configuration file can be changed to relatively large, but the upload of things relatively large do not do breakpoint continuation, the actual use of the time is very uncomfortable, often broken can only be re-transmitted, Https://github.com/blueimp/jQuery-File-Upload

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.