PHP code example of sparemusic / resumable-js

1. Go to this page and download the library: Download sparemusic/resumable-js 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/ */

    

sparemusic / resumable-js example snippets


'providers' => [
    // ...
    SpareMusic\ResumableJS\Providers\ResumableServiceProvider::class,
];

/**
 * Setup resumable instance
 */
public function setup()
{
    $chunkPath = Storage::disk('local')->path('chunks');
    $uploadPath = Storage::disk('local')->path('uploads');

    $this->setChunkPath($chunkPath)
        ->setUploadPath($uploadPath)
        ->setValidator(function (UploadedFile $file, ResumableParameters $parameters) {
            return true;
        });
}

Route::resumable("/upload", "UploadController@upload");

Route::get("/upload", "UploadController@upload");
Route::post("/upload", "UploadController@upload");

public function upload(SomeUpload $upload)
{
    $upload->process();

    if ($upload->isComplete()) {
        // File uploaded, do something with file
        // $upload->getFilename(true); filename with extension
        // $upload->getFilepath(); full filepath
    }

    return $upload->respond();
}
bash
php artisan make:resumable-request SomeUpload