1. Go to this page and download the library: Download shoperti/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/ */
shoperti / uploader example snippets
public function register()
{
$this->app->register(\Shoperti\Uploader\UploaderServiceProvider::class);
}
namespace App\Http\Controllers;
// Import the Shoperti Uploader Manager in your controller
use Shoperti\Uploader\Contracts\UploaderManager;
use Shoperti\Uploader\Exceptions\DisallowedFileException;
use Shoperti\Uploader\Exceptions\InvalidFileException;
use Shoperti\Uploader\Exceptions\RemoteFileException;
// To upload or delete a file, just inject the manager either in the constructor
// or in the action method
class Controller extends BaseController
{
/**
* Uploads a file.
*
* @param \Shoperti\Uploader\Contracts\UploaderManager $uploaderManager
*/
public function upload(UploaderManager $uploaderManager)
{
try {
/** @var \Shoperti\Uploader\UploadResult uploadResult */
$uploadResult = $uploaderManager
// generate an Uploader through the manager
// using the uploaded file or the file URL as argument
->make(request()->file('file') ?: request()->input('file'))
// then call the upload() method with the location path as argument
->upload($path = 'my_files', $disk = null);
} catch (DisallowedFileException $dfe) {
// If the uploaded file has a disallowed mime-type
} catch (InvalidFileException $ife) {
// If the uploaded file is invalid
} catch (RemoteFileException $rfe) {
// If the file input was a file-url string which cannot be fetched
}
}
/**
* Deletes a file.
*
* @param \Shoperti\Uploader\Contracts\UploaderManager $uploaderManager
*/
public function delete(UploaderManager $uploaderManager)
{
$uploaderManager
->delete($disk = 's3', $filepath = \Request::input('file'))
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.