georaldc / resumable-js-processor
轻松处理来自 Resumable.js 的上传
0.2.0
2016-06-30 19:42 UTC
Requires
- php: >=5.5
- symfony/filesystem: ^3.0
- symfony/http-foundation: ^3.0
Requires (Dev)
- mikey179/vfsstream: ~1
- phpunit/phpunit: ^4.8
README
轻松处理 resumable.js 上传。
在 resumable.js 的目标服务器文件内部,使用指定的上传路径实例化 ResumableJsProcessor 类,传递适当的模式(目前支持两种模式,请参阅 ResumableJsProcessor 常量)并调用 process() 方法。
$resumable = new ResumableJsProcessor('path/to/uploads'); if (isset($_FILES)) { $resumable->setMode(ResumableJsProcessor::MODE_UPLOAD_CHUNK); } else { $resumable->setMode(ResumableJsProcessor::MODE_TEST_CHUNK); } $fileUploaded = $resumable->process(); if (false !== $fileUploaded) { // $fileUploaded will contain the upload path + filename of file that has been uploaded. You may do further processing here }
此文件将针对每个检查和上传的块多次调用。一旦 ResumableJsProcessor::process() 返回一个字符串,则表示块已上传并组装完成。