Foreword
Will encounter many projects in uploading and downloading videos, update package, applications and other documents, such documents have in common is huge, I met about 4G files simultaneously downloading more than 100 machines in the project, if at this time with post upload and download can not think about, but Baidu said the search words are adjusted to limit post of php.ini, but this is a ridiculous solution, thus we need to use another solution - fragmentation upload and download speed limits
In this band we use php to achieve it, apply a variety of languages and frameworks, this is used in the php laravel, language and ideas to achieve the same
If used in the project part uploading, personal recommendations as to find the corresponding package (AetherUpload-Laravel), with 7 direct conditional cattle cloud, Ali cloud companies and other large fragments upload service
Part uploading
principle
- The uploaded file according to a certain division rule, the data is divided into blocks of the same size;
- Initializing a slice uploads, this return part uploading unique identifier;
- Sending each data block fragments according to a certain policy (serial or parallel);
- After the transmission is completed, the server is determined according to the data upload is complete, if incomplete, the data block synthesized original file.
achieve
h5
h5 achieve some, h5 partially achieved the split files, uploading, you tell the total number of pieces and the current file server is the first of several films, various temporary files sent via http request
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> #progress{ width: 300px; height: 20px; background-color:#f7f7f7; box-shadow:inset 0 1px 2px rgba(0,0,0,0.1); border-radius:4px; background-image:linear-gradient(to bottom,#f5f5f5,#f9f9f9); } #finish{ background-color: #149bdf; background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent); background-size:40px 40px; display: inline-block; height: 20px; } form{ margin-top: 50px; } </style> </head> <body> <p id="progress"> <span id="finish" style="width: 0%;" progress="0"></span> </p> <form action=""> <input type="file" name="file" id="file"> <input type="button" value="停止" id="stop"> </form> <script> var fileForm = document.getElementById("file"); var stopBtn = document.getElementById('stop'); var upload = new Upload(); fileForm.onchange = function(){ upload.addFileAndSend(this); } stopBtn.onclick = function(){ this.value = "停止中"; upload.