vmorozov / laravel-file-uploads
This package provides a convenient way to upload files to the cloud storage amazon s3 or locally fast in Laravel
Installs: 3 985
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 0
Open Issues: 2
Requires
- php: >=7.0
- illuminate/http: >=5.4
- illuminate/support: >=5.4
- intervention/image: ^2.4|^6.0
- league/flysystem: ^1.0
- league/flysystem-aws-s3-v3: ^1.0
README
A package for convenient way to upload files to the different storages
Installation
- Run the command below to add this package:
composer require vmorozov/laravel-file-uploads
- Open your
config/app.php
and add the following to the providers array:
Vmorozov\FileUploads\FileUploadsServiceProvider::class
- Run the command below to publish the package config file config/file_uploads.php:
php artisan vendor:publish
Configuration
Go to the file
config/file_uploads.php
There you have an ability to set:
- default storage to upload file (default is: local)
- default image quality (default is: 100)
- default folder to put your uploads (default is: public/user-uploads)
Usage
To upload file:
public function store(Request $request) { // This will upload your file to the default folder of selected in config storage Uploader::uploadFile($request->file('some_file')); // This will upload your file to the given as second parameter path of default storage Uploader::uploadFile($request->file('some_file'), 'path/to/upload'); // This will upload your file to the given storage Uploader::uploadFile($request->file('some_file'), 'path/to/upload', 'storage_name'); // This will also resize image to the given width and height Uploader::uploadFile($request->file('some_file'), 'path/to/upload', 'storage_name'); }
To upload base64 string of image:
public function store(Request $request) { // This will upload your file to the default folder of selected in config storage Uploader::uploadBase64Image($request->input('image')); // This will upload your file to the given as second parameter path of default storage Uploader::uploadFile($request->input('image'), 'path/to/upload'); // This will upload your file to the given storage Uploader::uploadFile($request->input('image'), 'path/to/upload', 'storage_name'); // This will also resize image to the given width and height Uploader::uploadFile($request->input('image'), 'path/to/upload', 'storage_name'); }