1. Go to this page and download the library: Download hamed/php-chunk-file-upload 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/ */
hamed / php-chunk-file-upload example snippets
composer
use Hamed\ChunkFile\Uploader;
...
try {
$file_path = (new Uploader())->Upload([
'chunk_path' => $request->file('file')->getRealPath(),
'file_name' => $request->resumableFilename,
'chunk_number' => $request->resumableChunkNumber,
'chunks_count' => $request->resumableTotalChunks,
'file_size' => $request->resumableTotalSize,
'max_upload' => 5 * pow(10, 6),
'errors' => ['max_upload' => "Low Space"],
]);
} catch (Exception $exception) {
return response($exception->getMessage(), 403);
}
if (is_string($file_path)) echo("File path: $file_path"); // Upload has finished. You can move the file.
else echo("Progress: {$file_path}%") // Chunk has been uploaded. Print the percentage of the upload ;)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.