1. Go to this page and download the library: Download gpit/fileuploader 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/ */
gpit / fileuploader example snippets
use gpit\fileuploader\FileUploader;
use Illuminate\Http\Request;
class ProfileController extends Controller
{
/**
* Upload a profile image.
*
* @param \Illuminate\Http\Request $req
* @return array
*/
public function profileImg(Request $req)
{
// Optional custom path
$customPath = 'profile/images';
// Use FileUploader with the custom path
$result = FileUploader::uploadFile($req, $customPath);
if ($result[0]) {
return ['success' => true, 'path' => $result['path']];
} else {
return ['success' => false, 'error' => $result['error']];
}
}
}
$customPath = 'profile/images';
FileUploader::uploadFile($request, $customPath); // Files will be uploaded to 'profile/images/'
FileUploader::uploadFile($request); // Files will be uploaded to 'files/'
[true, 'path' => 'profile/images/avatar.png']
[false, 'error' => 'Error message here']
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.