Download the PHP package royalcms/uploader without Composer
On this page you can find all versions of the php package royalcms/uploader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download royalcms/uploader
More information about royalcms/uploader
Files in royalcms/uploader
Package uploader
Short Description The Royalcms uploader package.
License MIT
Homepage http://royalcms.cn
Informations about the package uploader
Royalcms Uploader
Uploading files and store its in Filesystem / Cloud storage in Royalcms 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.
Configuration
The Uploader configuration is located at packages/royalcms/uploader/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 RC_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 [Filesystem] 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: