PHP code example of mehrdad-dadkhah / chunks-uploader

1. Go to this page and download the library: Download mehrdad-dadkhah/chunks-uploader 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/ */

    

mehrdad-dadkhah / chunks-uploader example snippets


use MehrdadDadkhah\Video\ChunksUploader;

$uploadHandeler = new ChunksUploader();
$uploadHandeler->setMainFileName('myFile.mp4') //main file name
            ->setFileTotalSize($_REQUEST['totalfilesize']) //size of main file (big file)
            ->setInputName('file') //your form input file name
            ->setChunksFolderPath('path-to-chunks-folder') //path to folder for upload chunks files
            ->setUniqueIdentifier('unique-id'); // set unique identifier for each upload (for example user id + time or ...) a unique indentifier per each upload

$uploadResult = $uploadHandeler->uploadChunk('name-of-chunk-or-chunk-number'); //should be a sortable name

$uploadResult = $uploadHandeler->setUploadDirectory('path-to-upload-directory') //main directry path to upload (combine chunks here)
			->finishUpload();

$uploadHandeler->setUploadName('my-name.mp4');

$uploadHandeler->checkAndGenerateOutputDirectory();

$uploadHandeler->setTempDirectory('path-to-temp');

$uploadHandeler->setVideoTotalSize(213456);

$uploadHandeler->setMaxUploadSize(213456);