PHP code example of sdtech / file-uploader-laravel
1. Go to this page and download the library: Download sdtech/file-uploader-laravel 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/ */
sdtech / file-uploader-laravel example snippets
'providers' => [
// Other Service Providers...
Sdtech\FileUploaderLaravel\Providers\FileUploadLaravelServiceProviders::class,
],
use Sdtech\FileUploaderLaravel\Service\FileUploadLaravelService;
class UploadController extends Controller
{
public function uploadImg(Request $request) {
$service = new FileUploadLaravelService();
$reqFile = $request->img;
$path = 'uploads';
$response = $service->uploadImageInStorage($reqFile,$path);
return $response;
}
}
in the same way you can use other function as well
@param FILE $reqFile (mandetory) uploaded file
@param STRING $path (mandetory) file path where upload iamge
@param STRING $oldFile (optional) old file name // $oldFile = '1720705563668fe21b791d2.png';
@param ARRAY $allowedImageType (optional) allowed image type like ["png","webp","jpeg"]
@param INT $maxSize (optional) max upload size in KB 1024KB = 1MB
@param STRING $format (optional) image output format default = webp
@param INT $width (optional) image width
@param INT $height (optional) image height
@param INT $quality (optional) image quality default = 80