1. Go to this page and download the library: Download cesurapp/storage-bundle 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/ */
use Cesurapp\StorageBundle\Storage\Storage;
class FileController
{
public function upload(Storage $storage): void
{
// Upload file (uses default device)
$storage->upload('/tmp/photo.jpg', 'users/123/photo.jpg');
// Write content directly
$storage->write('Hello World', 'documents/hello.txt', 'text/plain');
// Check if file exists
if ($storage->exists('users/123/photo.jpg')) {
// Get file URL
$url = $storage->getUrl('users/123/photo.jpg');
// Get file size
$size = $storage->getSize('users/123/photo.jpg');
// Get MIME type
$mime = $storage->getMimeType('users/123/photo.jpg');
}
// Download file content
$content = $storage->download('users/123/photo.jpg');
// Download as resource
$resource = $storage->downloadResource('users/123/photo.jpg');
// Download as chunks (cloud only)
foreach ($storage->downloadChunk('large-file.zip') as $chunk) {
echo $chunk;
}
// Delete file
$storage->delete('users/123/photo.jpg');
}
}
// Use a specific storage device instead of default
$storage->device('local')->upload('/tmp/file.pdf', 'documents/file.pdf');
$storage->device('backblaze')->upload('/tmp/backup.zip', 'backups/backup.zip');
$uploadUrl = $storage->device('main')->private()->getPresignedPutUrl(
'recordings/2026/07/call.webm',
new \DateTimeImmutable('+1 hour')
);
// The uploader then does: PUT $uploadUrl, Content-Type: video/webm, body: <bytes>
$localDriver = $storage->device('local');
// Get file hash (MD5)
$hash = $localDriver->getFileHash('documents/file.pdf');
// Get directory size
$size = $localDriver->getDirectorySize('users/123/');
// Get partition free space
$freeSpace = $localDriver->getPartitionFreeSpace();
// Get partition total space
$totalSpace = $localDriver->getPartitionTotalSpace();
// Move file
$localDriver->move('/tmp/file.pdf', 'documents/moved-file.pdf');
// Delete directory
$localDriver->deletePath('temp/uploads/');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.