code-lts / resumable.php
PHP package for Resumable.js
dev-main
2024-05-31 21:50 UTC
Requires
- php: ^8.1
- knplabs/gaufrette: ^0.11.1
- ondrej-vrto/php-filename-sanitize: ^1.4
- psr/http-message: ^1.0
- psr/log: ^2 || ^3
Requires (Dev)
- nyholm/psr7: ^1.4
- phpunit/phpunit: ^10
- wdes/coding-standard: ^3.0
This package is auto-updated.
Last update: 2024-12-01 00:09:05 UTC
README
To use this project we recommend you to use point cloud technology's fork that is a maintained version of the original resumable.js library.
Installation
To install, use composer:
composer require code-lts/resumable.php
How to use
upload.php
<?php include __DIR__ . '/vendor/autoload.php'; use ResumableJs\Resumable; // Any library that implements Psr\Http\Message\{ServerRequestInterface, ResponseInterface}; // See https://github.com/Nyholm/psr7 as a tested example $resumable = new Resumable($request, $response); $resumable->tempFolder = 'tmps'; $resumable->uploadFolder = 'uploads'; $resumable->process();
More
Setting custom filename(s)
$originalName = $resumable->getOriginalFilename(); // will give you the original end-user file-name $mySafeName = Security::sanitizeFileName($request->query('resumableFilename')); $resumable->setFilename($mySafeName);// Override the safe filename // process upload as normal $resumable->process(); // you can also get file information after the upload is complete if (true === $resumable->isUploadComplete()) { // true when the final file has been uploaded and chunks reunited. $filename = $resumable->getFilename(); }
Removed features
$resumable->getOriginalFilename()
does not have a parameter to return the name without the extension$resumable->getExtension()
implement the logic yourselfpreProcess()
no longer exists, it was not very useful- the default value of
uploadFolder
wastest/files/uploads
and is nowuploads
- Does not calculate the number of chunks, it uses the param
resumableTotalChunks
Testing
$ ./vendor/bin/phpunit