samankhdev / lara-file
This package of Laravel helps you to upload multiple files.
v2.3.3
2021-10-22 03:06 UTC
Requires
- php: ^7.2 || ^8.0
- illuminate/support: ~8
README
This package helps you, in addition to uploading multiple files for each file, specify which disk it should be on or which folder it should be in.
- The Package
ramsey/uuid
is used to hash file names.
Installation
composer require samankhdev/lara-file
Version 2
- Example
Single upload file
$laraFile = new LaraUpload();
$laraFile->push($request->img, "products/img");
$laraFile->send();
#tips
- first param is your file
- second param is location of this file
- and last param choose disk default is
public
and optional - for example =>
products/img
will be inpublic/products/img
in -> storage - the result of push method is
boolean
Multiple upload files
$laraFile = new LaraUpload();
$laraFile->pushMany([
[
'dir'=>'images',
'file'=>$request->file,
'disk'=>'privateImages' //default is `public`
],...
]);
$laraFile->send();
Config
- to change default -> default disk and default directory
pa vendor:publish
- now you can see a file named laraFile.php in config directory .
Version 1
Usage
- Example
- Simple Uploading
$files = [];
foreach ($request->file as $file) {
array_push($files, [
"file" => $file
]);
}
$lara = new LaraUpload($files);
$lara->send();
- In this example I want Upload my files in
public/images/
$files = [];
foreach ($request->file as $file) {
array_push($files, [
'dir'=>'images',
"file" => $file
]);
}
$lara = new LaraUpload($files);
$lara->send();
- In Another example I change disk
$files = [];
foreach ($request->file as $file) {
array_push($files, [
'dir'=>'images',
'disk'=>'PrivateFiles',
"file" => $file
]);
}
$lara = new LaraUpload($files);
$lara->send();