georaldc/resumable-js-processor

Easily handle uploads coming from Resumable.js

0.2.0 2016-06-30 19:42 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:58:11 UTC


README

Build Status

Easily handle resumable.js uploads.

Inside target server file for resumable.js, instantiate the ResumableJsProcessor class with your intended upload path specified, pass the appropriate mode (supports 2 modes at the moment, see ResumableJsProcessor constants) and call the process() method.

$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
}

This file will be called multiple times for every chunk checked and uploaded. Once ResumableJsProcessor::process() returns a string, that will be indication that the chunks have been uploaded and assembled.