PHP code example of code-lts / resumable.php

1. Go to this page and download the library: Download code-lts/resumable.php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

code-lts / resumable.php example snippets



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();


$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();
}