Php resumable Upload

Source: Internet
Author: User
Php does not use the control for resumable Upload. does it seem that it can only be implemented in flash?


Reply to discussion (solution)

Of course. Php does not support it.

If you do not use controls, it seems that you can only use flash to implement them? It is not easy to implement without controls. You can see the large attachment Upload function in QQ mailbox, Baidu online storage, DBank (Huawei online storage), 115 online storage, 360 network disks all their breakpoint resume functions are implemented by self-developed controls. Instead of using Flash.

If you do not use controls, it seems that you can only use flash to implement them? In the actual network environment, files of about 30 MB need to be implemented by using controls. On the one hand, it is because the network environment in China is not stable, and on the other hand, it is based on the server load.
Under normal circumstances, some of our website users may use the telecom network, some of which are the Unicom network, some are the education network, and some are the South and the North, this complex network environment leads to different website access speeds. Some users have fast network speeds. for example, if a telecom user accesses a telecom data center, it must be fast. Therefore, uploading large files may be okay. However, China Unicom's access to China Telecom's data center may be slow. when uploading large files, it may encounter problems such as upload timeout and disconnection.

Due to server load problems, the normal file upload technology is still very stressful on the server. For uploading files of 1 GB in common HTML, the server needs to allocate 1 GB of memory first, and then open a persistent connection until the client completes the upload. During this period, if other users need to upload 1 GB of files, the server will allocate 1 GB of memory. As you can imagine, if there are more users, the server will definitely be unable to handle the issue. Even if Flash is used, for example, swfupload has several other Flash controls. they use the same technology as ordinary HTML.

Tencent has considered this problem, so it uses controls to solve this problem. They divide a large file, such as 1 GB, into many small blocks, each of which is about KB, and then upload them cyclically until the upload is complete. This reduces the pressure on the server, improves the server load capability, and increases the number of user requests that the server can process. It also saves costs.

If you do not use controls, it seems that you can only use flash to implement them? The traditional HTML method is difficult to upload large files. In other words, it is 100 MB. 50 MB is very large for the server. the service not only requires a dedicated socket connection, but waits until the file is uploaded, we also need to allocate the same size of memory to save this file, which puts a considerable amount of pressure on the server, and this pressure will become a geometric increase as the user increases. Even if Flash is used, Flash does not support resumable Upload and file multipart Upload. Flash works the same way as traditional HTML Upload. When uploading MB images in Flash, the server also needs to allocate MB of memory. If 10 users Upload MB of data at the same time, they need to eat 1 GB of memory on the server.
During Flash upload, the entire file is added to the memory, which is a serious problem. Because if you want to upload 5G files, Flash will also load all 5G files into the memory. This will seriously affect the user experience. This is because the user's computer is in a false state. Generally, the user's computer is 2 GB, so the user crashes directly, the memory is insufficient, or the memory overflows.

Some friends have tried to use the Flash file upload control to upload large files, but they often encounter Upload timeout or upload errors. This is because the current Flash file upload control uses the same technology as the traditional HTML Upload method. Let the server open a connection and wait until the client finishes uploading the file. However, in the actual network environment, the user's network speed may be only 50 kB/S, and uploading a 2.8 MB file may take hours. However, the SESSION connection on the server cannot be 2.8 hours for the user. This does not take into account complex network environments, such as packet loss. In case of packet loss and network exceptions, the first MB file is passed in white. This is a waste of one hour. It provides users with a very poor experience.
For the server, the connection resources are very limited. even if the server can wait 2.8 hours for a user to access a large number of resources, each user occupies a connection and takes such a long time, the server's concurrent processing capability becomes very low. Other users even request a simple 1 kb html page and wait for the server to process the previous user request.

At the same time, Flash cannot meet the upload needs of ultra-large files. The requirement for uploading large files is to ensure the stability of data transmission. For example, if a user uploads a 1g file and has already uploaded 500 MB, the network is suddenly disconnected, but the user wants to transfer the file from the last uploaded location next time, that is, transmission starts from a location of MB, which cannot be implemented by Flash.

Like the large attachment Upload function in QQ mail, the ultra-large attachment Upload control in 115 network disk, Huawei network disk (DBank), and Kingsoft fast disk all use controls to upload ultra-large files. In this way, the server load is reduced (the server response time is faster and the concurrent processing capability is stronger), saving the server memory (the server does not have to allocate the same size of memory for each user as the file ), it also improves user experience (users can upload large files in complex network environments ).

Of course, from a technical point of view, well-known Internet enterprises also consider the distributed file storage architecture design that supports massive users. Because their file storage server cannot be one and will dynamically increase with the increase of the number of users.

If some friends say that the Flash control can solve the problem of uploading ultra-large files, Teng Xun will not spend so much effort to develop a control for QQ mail.

If you do not use controls, it seems that you can only use flash to implement them? The biggest problem with resumable data transfer using PHP or Flash is how to upload 1 GB of data to the Web server at a time. Flash has a big problem in processing ultra-large files due to security issues.

Flash also belongs to the control category
Resumable upload is easier to implement than resumable download.

As long as it is resumable data transfer, it is a matter for both parties, and both ends must be supported.

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.