PHP code example of danilowa / laravel-easy-cloud-storage
1. Go to this page and download the library: Download danilowa/laravel-easy-cloud-storage 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/ */
danilowa / laravel-easy-cloud-storage example snippets
use Danilowa\LaravelEasyCloudStorage\Facades\EasyStorage;
// Assume $uploadedFile is an instance of UploadedFile, obtained from an HTTP request.
$filePath = EasyStorage::upload($uploadedFile, 'uploads/myfile.txt')
->withLog(true) // Set error logging behavior. Defaults to true if not specified.
->withError(false) // Set error handling behavior. Defaults to true if not specified.
->setDisk('s3'); // Specify the disk manually instead of using the default.
// Check if the upload was successful
if($filePath === false) {
return echo "Error uploading the file.";
}
echo "File uploaded successfully: $filePath";
$filePath = EasyStorage::upload($uploadedFile, 'uploads/myfile.txt', 'banana.txt');
// Upload to a specific disk (S3)
$filePathS3 = EasyStorage::upload($uploadedFile, 'uploads/myfile.txt')->setDisk('s3');