1. Go to this page and download the library: Download royalcms/uploader 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/ */
royalcms / uploader example snippets
RC_Uploader::from('request')->upload('avatar'); // see the supported providers at config/uploader.php
// Or you can use the magic methods...
RC_Uploader::fromRequest()->upload('file');
RC_Uploader::fromLocal()->upload('/path/to/file');
// If your default provider is local, it will automatically use the local provider.
RC_Uploader::upload('/path/to/file');
namespace App\Http\Controllers;
use RC_Uploader;
use Royalcms\Component\Http\Request;
class UserController extends Controller
{
/**
* Change user's avatar.
*
* @param \Royalcms\Component\Http\Request $request
* @return \Royalcms\Component\Http\Response
*/
public function changeAvatar(Request $request)
{
RC_Uploader::upload('avatar');
//
}
}
// The parameter in the Closure is a full uploaded filename...
RC_Uploader::upload('avatar', function ($filename) {
Photo::create(['photo' => $filename]);
});
RC_Uploader::upload('/path/to/file', function ($filename) {
$user = User::find(12);
$user->update(['avatar' => $filename]);
});
// see the supported uploadTo parameter at config/filesystems.php
RC_Uploader::uploadTo('s3')->upload('avatar');
// Or you can use the magic methods...
RC_Uploader::uploadToS3();
RC_Uploader::uploadToFtp();
RC_Uploader::uploadToLocal();
RC_Uploader::uploadToRackspace();