mehrdad-dadkhah / php-fine-uploader
上传分块文件。用于上传大文件
1.3.0
2017-09-26 13:34 UTC
Requires
- php: >=7.0
- mehrdad-dadkhah/chunks-uploader: ^1.2
README
php 库,用于将 fine-uploader js 作为客户端上传大文件,并将文件分割成多个块。此库基于 chunks-uploader。
安装
composer require mehrdad-dadkhah/php-fine-uploader
使用方法
use MehrdadDadkhah\Video\FineUploader; $uploaderService = new FineUploader(); $uploadResult = $uploaderService->setConfigs( 'form-input-name', 'path-to-chunks-folder' ) ->setUniqueIdentifier('unique-identifier') ->setDomain('http://example.com') //to set cors header ->checkDublicateFile(function($uuid) { //closure function to check file is duplicate or not it should get $uuid as input and return boolean. uuid is a video unique hash return false; }) ->upload('path-to-upload-directory');
自定义文件名
如果想要设置输出文件名,请在调用 finishUpload() 函数之前使用 setUploadName() 函数
$uploadHandeler->setUploadName('my-name.mp4');
如果不设置名称,文件名将具有结构 YYYY_m_d_hashname.mp4,在最终结果中返回的名称将是生成的名称。
检查和生成输出目录
如果想要脚本自动创建输出目录,请设置它
$uploadHandeler->checkAndGenerateOutputDirectory();
临时目录
如果想要在临时目录中生成文件,然后将其移动到主上传目录,可以使用 setTempDirectory() 函数
$uploadHandeler->setTempDirectory('path-to-temp');
最大上传大小
ChunksUploader 计算上传文件大小(块的总和)并与 upload_max_filesize ini 配置进行比较。如果想要在第一次请求时停止更大的文件以获得更好的用户体验,可以传递总主文件大小(以字节为单位)
$uploadHandeler->setVideoTotalSize(213456);
并且可以通过以下方式覆盖 upload_max_filesize
$uploadHandeler->setMaxUploadSize(213456);
许可
hls-video-generater 在 GPLv3 许可 下发布。