Below could work
if ($request->file('card')){
$request->file('card')->type('card');
$files[] = $request->file('card');
}
Hello ,
I have a problem determining which input it's uploading each file. I have 3 inputs that post only images but each one it's labeled and the person who uploads should upload the specific file in the specific input. They are in total 3 inputs for uploading files , but i cant figure it out how to know which input was posted in order to rename the file according to it.
For retrieving the post i use the following code :
public function store(Request $request) { $this->validate($request, [ 'buletin' => 'mimes:jpeg,jpg,png,bmp', 'factura' => 'mimes:jpeg,jpg,png,bmp', 'card' => 'mimes:jpeg,jpg,png,bmp', ]); $username = $request->input('username');
$files = [];
if ($request->file('buletin'))
{
$files[] = $request->file('buletin');
}
if ($request->file('factura')){
$files[] = $request->file('factura');
}
if ($request->file('card')){
$files[] = $request->file('card');
}
foreach($files as $file){
dd($file);
$img = Image::make($file)->encode('jpg', 75)->resize(1024,768);
$fileFileName = $username . '_// the document name according to the name of the form ';
$filePath = '/'.$username.'/' . $fileFileName;
$document = new DocumentModel();
$document->username = $username;
$document->document = // the document name according to the name of the form
$document->filename = $fileFileName;
$document->filepath = $filePath;
$document->save();
}
}
Does anyone have an idea how to achieve this ?
Thank you
Please or to participate in this conversation.