超巨 發表於 2019-8-6 14:18:00

php+上传视频大文件

<p style="word-wrap: break-word; margin: 3.75pt 0; font-family: &quot;sans serif&quot;, tahoma, verdana, helvetica; font-size: 12px"><span style="font-size: 9pt"></span></p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">理清思路:</p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">引入了两个概念:块(block)和片(chunk)。每个块由一到多个片组成,而一个资源则由一到多个块组成</p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">块是服务端的永久数据存储单位,片则只在分片上传过程中作为临时存储的单位。服务端会以约一个月为单位周期性的清除上传后未被合并为块的数据片</p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">实现过程:</p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">将文件分割,分片上传,然后合并</p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">前端核心code:</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">var fileForm = document.getElementById("file");</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var upstartBtn = document.getElementById('upstart');</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var stopBtn = document.getElementById('stop');</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var startBtn = document.getElementById('restart');</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var rate = document.getElementById('rate');</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var divlog = document.getElementById('divlog');</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; //---------------------------</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; const LENGTH = 1024 * 1024 * 1;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var start = 0;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var end = start + LENGTH;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var blob;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var blob_num = 1;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var is_stop = 0</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var file = null; &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var md5filename = '';</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; //-----------------------------</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; var upload_instance = new Upload();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; fileForm.onchange = function()</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; {</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; browserMD5File(fileForm.files, function (err, md5) { //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">如果文件大,md5值生成较慢 &nbsp;md5值生成后才能上传处理,自己优化下吧</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; md5filename = md5; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">如果需要刷新后也能断点,可利用cookie记录,自行完善 &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; divlog.innerHTML = '</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">文件md5为:' + md5filename;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; });</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; upstartBtn.onclick = function(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; upload_instance.addFileAndSend(fileForm);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; stopBtn.onclick = function(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; upload_instance.stop();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; startBtn.onclick = function(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; upload_instance.start();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; function Upload(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; var xhr = new XMLHttpRequest();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; var form_data = new FormData();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">对外方法,传入文件对象</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; this.addFileAndSend = function(that){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; file = that.files;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; blob = cutFile(file);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; sendFile(blob,file);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; blob_num += 1;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">停止文件上传</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; this.stop = function(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; xhr.abort();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; is_stop = 1;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; this.start = function(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; sendFile(blob,file); &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; is_stop = 0;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">切割文件</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; function cutFile(file){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; var file_blob = file.slice(start,end);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; start = end;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; end = start + LENGTH;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; return file_blob;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; };</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">发送文件</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; function sendFile(blob,file){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; var total_blob_num = Math.ceil(file.size / LENGTH);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; form_data.append('file',blob);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; form_data.append('blob_num',blob_num);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; form_data.append('total_blob_num',total_blob_num);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; form_data.append('md5_file_name',md5filename);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; form_data.append('file_name',file.name);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; xhr.open('POST','./index.php',false);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; xhr.onreadystatechange = function () {</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; var progress;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; var progressObj = document.getElementById('finish');</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; if(total_blob_num == 1){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progress = '100%';</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; }else{</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; progress = (Math.min(100,(blob_num/total_blob_num)* 100 )).toFixed(2) +'%';</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; console.log('progress-----'+progress);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; progressObj.style.width = progress;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; rate.innerHTML = progress;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; var t = setTimeout(function(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(start &lt; file.size &amp;&amp; is_stop === 0){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blob = cutFile(file);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendFile(blob,file);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; blob_num += 1;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //setTimeout(t);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; },1000);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; xhr.send(form_data);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-size: 10.5pt; background: rgba(224, 224, 224, 1); font-family: Calibri, sans-serif">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">后端code</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&lt;?php</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">class Upload{</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private $filepath = './upload'; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">上传目录</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private $tmpPath; //PHP</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">文件临时目录</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private $blobNum; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">第几个文件块</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private $totalBlobNum; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">文件块总数</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private $fileName; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">文件名</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private $md5FileName;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; public function __construct($tmpPath,$blobNum,$totalBlobNum,$fileName, $md5FileName){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $this-&gt;tmpPath = $tmpPath;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $this-&gt;blobNum = $blobNum;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $this-&gt;totalBlobNum = $totalBlobNum;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $this-&gt;fileName = $this-&gt;createName($fileName, $md5FileName);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $this-&gt;moveFile();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $this-&gt;fileMerge();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">判断是否是最后一块,如果是则进行文件合成并且删除文件块</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private function fileMerge(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; if($this-&gt;blobNum == $this-&gt;totalBlobNum){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; $blob = '';</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; for($i=1; $i&lt;= $this-&gt;totalBlobNum; $i++){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; $blob .= file_get_contents($this-&gt;filepath.'/'. $this-&gt;fileName.'__'.$i);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; file_put_contents($this-&gt;filepath.'/'. $this-&gt;fileName,$blob);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; $this-&gt;deleteFileBlob();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; //</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">删除文件块</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private function deleteFileBlob(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; for($i=1; $i&lt;= $this-&gt;totalBlobNum; $i++){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; @unlink($this-&gt;filepath.'/'. $this-&gt;fileName.'__'.$i);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private function moveFile(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $this-&gt;touchDir();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; $filename = $this-&gt;filepath.'/'. $this-&gt;fileName.'__'.$this-&gt;blobNum;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; move_uploaded_file($this-&gt;tmpPath,$filename);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; //API</span><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">返回数据</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; public function apiReturn(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; if($this-&gt;blobNum == $this-&gt;totalBlobNum){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; if(file_exists($this-&gt;filepath.'/'. $this-&gt;fileName)){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['code'] = 2;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['msg'] = 'success';</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['file_path'] = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['DOCUMENT_URI']).str_replace('.','',$this-&gt;filepath).'/'. $this-&gt;fileName;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }else{</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; if(file_exists($this-&gt;filepath.'/'. $this-&gt;fileName.'__'.$this-&gt;blobNum)){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['code'] = 1;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['msg'] = 'waiting';</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $data['file_path'] = '';</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; header('Content-type: application/json');</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; echo json_encode($data);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private function touchDir(){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; if(!file_exists($this-&gt;filepath)){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; return mkdir($this-&gt;filepath);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; private function createName($fileName, $md5FileName){</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp;return $md5FileName . '.' . pathinfo($fileName)['extension'];</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">&nbsp; }</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">}</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">$upload = new Upload($_FILES['file']['tmp_name'],$_POST['blob_num'],$_POST['total_blob_num'],$_POST['file_name'],$_POST['md5_file_name']);</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background: rgba(224, 224, 224, 1)"><span style="box-sizing: border-box; font-size: 9pt; font-family: 新宋体; color: rgba(0, 0, 0, 1)">$upload-&gt;apiReturn();</span></p><p style="box-sizing: border-box; margin: 0 0 0.0001pt; color: rgba(51, 51, 51, 1); font-size: 10.5pt; background: rgba(224, 224, 224, 1); font-family: Calibri, sans-serif">&nbsp;</p><p style="box-sizing: border-box; margin: 0 0 10px; color: rgba(51, 51, 51, 1); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgba(255, 255, 255, 1)">效果展示:<br style="box-sizing: border-box"><img width="438" height="460" src="http://bbsres2.ncmem.com/e572f456.png" alt="https://img-blog.csdnimg.cn/20181205120139594.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2JjdWlkZW5naG9uZw==,size_16,color_FFFFFF,t_70" style="box-sizing: border-box; border-width: 0; vertical-align: middle; height: auto; width: auto; max-width: 100%"><br style="box-sizing: border-box">详细代码可参考我写的这篇文章:http://blog.ncmem.com/wordpress/2019/08/12/php%e4%b8%8a%e4%bc%a0%e5%a4%a7%e6%96%87%e4%bb%b6-3/</p><p style="word-wrap: break-word; margin: 0 0 0.0001pt; font-family: Calibri, sans-serif; font-size: 10.5pt"></p><br><br>
来源:https://www.cnblogs.com/songsu/p/11308620.html
頁: [1]
查看完整版本: php+上传视频大文件