File upload-php uploads large files (more than MB)

Source: Internet
Author: User
Tags php file upload
How does php upload large files? the configuration seems to be set to a maximum of 8 MB. I want to know how to upload a file of several hundred MB (no special client software is used ), it seems like you want to partition something. do you know how to do this? How does php upload large files? in the configuration, it seems that the maximum value is 8 MB, I want to know how to upload a file of several hundred MB (no special client software is used). It seems that I want to fragment something. do you know how to do it?

Reply content:

How does php upload large files? the configuration seems to be set to a maximum of 8 MB. I want to know how to upload a file of several hundred MB (no special client software is used ), it seems like you want to partition something. do you know how to do it?

Apache/Nginx on the server supports resumable data transfer and cURL on the client supports resumable data transfer.
By default, the browser supports resumable Upload. you can use jQuery-File-Upload to implement multipart Upload and resumable Upload. the server uses PHP to receive resumable Upload.
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
To avoid large file upload blocking PHP service, you can open a separate PHP-FPM process pool for upload, using the isolation of the pool provided by the PHP-FPM, separation of computing intensive and I/O intensive (upload) operation to reduce the impact of blocking on the entire PHP application.

Additional instructions:

Info. php
              
          Php file upload test                
              

Nginx and PHP-FPM work process are opened only one.
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 = 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 status, and nginx and fpm are not blocked.

Top-p 4075: Nginx single thread is visible. sudo strace-p 4075: Nginx calls recvfrom to receive data and pwrite saves the data. sudo strace-p 13751 visible the PHP-FPM is acquired only when Nginx receives the data uploaded by the user.

In this case, the FPM process pool I previously imagined is not very useful for processing Upload operations. the PHP-FPM is not blocked during File upload because Nginx receives the uploaded content before being handed over to the PHP-FPM at a time.
Attachment: Download images 2 Kb per second

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

Use a third-party breakpoint resume control (activex control)

For example, Xproer. HttpUploader5 is similar to the large attachment of QQ mail.

Or use SWFUpload, which is said to support up to 2 GB

Php configuration file can be changed to a relatively large, but the upload is relatively large do not resumable upload, the actual use of the 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.