Download the PHP package rymanalu/laravel-simple-uploader without Composer
On this page you can find all versions of the php package rymanalu/laravel-simple-uploader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rymanalu/laravel-simple-uploader
More information about rymanalu/laravel-simple-uploader
Files in rymanalu/laravel-simple-uploader
Package laravel-simple-uploader
Short Description Simple file uploader for Laravel 5.
License MIT
Homepage https://github.com/rymanalu/laravel-simple-uploader
Informations about the package laravel-simple-uploader
Laravel 5 Simple Uploader
Uploading files and store its in Filesystem / Cloud storage in Laravel 5 is not easy and simple for some developers. This package provides a simple way to do that, and comes with fluent interface that you might like.
Installation
First, install this package via the Composer package manager:
Next, you should add the UploaderServiceProvider
to the providers
array of your config/app.php
configuration file:
Don't forget to add the Uploader
facade to the aliases
array for shorter code:
After that, you should publish the Uploader configuration using the vendor:publish
Artisan command. This command will publish the uploader.php
configuration file to your config
directory:
Configuration
The Uploader configuration is located at config/uploader.php
, where you can adjust the default file provider and the default file visibility as you want.
File Providers
This package comes with two file providers, from HTTP request and local filesystem. Before uploading a file, you can set where the file is provided. Example:
If you call method on the Uploader
facade without first calling the from
method, the uploader will assume that you want to use the default provider.
Usage
Uploading a File
Now, uploading a file is very simple like this:
The upload
method accept a request key or path where the file is located (based on the file provider) as first parameter and returns a boolean: true
if succeed or false
if failed.
You may pass a Closure
callback as second parameter that will be called if the file successfully uploaded:
Choosing the File Storage
Automatically, the Uploader will use your default Filesystem Disk when storing the file. But, you can choose where you will store the file with uploadTo
method:
Set the Folder
Maybe you want to specify the folder where the file will be stored. Just use the toFolder
method:
Rename the File
Adjust the filename as you want with renameTo
method:
If you ignore this method, the file will be renamed to random and unique name.
File Visibility
You may set the file visibility using the setVisibility
method:
Or just ignore this, and the Uploader will set the visibility based on your configuration.
Method Chainning
All the methods above except the upload
method, are chainable. Feel free to call other methods before calling the upload
. Example:
Adding Custom File Provider
Implementing The Provider
Your custom file provider should implement the Rymanalu\LaravelSimpleUploader\Contracts\Provider
. This interface contains just a few simple methods we need to implement. A stubbed Google Drive implementation looks something like this:
Registering The Provider
Once your provider has been implemented, you are ready to register it with the UploaderManager
. To add additional drivers to the manager, you may use the extend
method on the Uploader
facade. You should call the extend
method from the boot method of a service provider. You may do this from the existing AppServiceProvider
or create an entirely new provider:
Once the provider driver has been registered, you may use the gdrive
driver in your config/uploader.php
configuration file.
All versions of laravel-simple-uploader with dependencies
illuminate/http Version ^5.0
illuminate/support Version ^5.0
illuminate/contracts Version ^5.0