Topic: Plugin File upload
Maximilian Schulze pro premium priority asked 2 years ago
Hi, I am currently trying to upload multiple files in laravel using the File upload plugin. I noticed that you can add several files individually via the plugin. When I do this, I have 3 images in the view but only the last one is uploaded. If I upload all 3 directly, all 3 are uploaded. Is there a solution for this?
jobs.blade.php
<form method="post" action="..." multipart="" enctype="multipart/form-data">
<input
id="dnd-multiple-files"
name="upload[]"
type="file"
class="file-upload-input"
data-mdb-multiple="true"
data-mdb-file-upload="file-upload"
data-mdb-accepted-extensions=".png, .pdf, .jpg"
multiple
required
/>
...
JobsFormController.php
//Files
$files = $request->file('upload');
$filePaths = [];
dd($request->file('upload')); //Problem...
Grzegorz Bujański staff answered 2 years ago
bfwien pro premium priority answered a year ago
We just updated to the newest version of MDB because we needed the possibilty to upload multiple files at once and this function was broken in 4.2.
Now we have 7.1 and facing this problem described here - stil not fixed after 6 months. Passing multiple files in a form is a basic functionalty a plugin that is designed for file uploads should provide. And no, the event-listener is not a clean solution to this, because you need to use several workaround from PHP to Javascript to handle uploading and removing of files this way.
Can you please look into this?
Grzegorz Bujański staff answered a year ago
We have a fix ready, but we need to test it. We will try to release a revised version as soon as possible.
But adding files one by one is not supported with input type="file"
. Adding another file overwrites value. File upload is an extension to native input
that allows you to add files using drag and drop feature. So we are limited by the capabilities of the native input
type="file"
.
We will fix preview display showing what has been added to the input. But adding multiple files will only be possible if you add them all at once.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.3.0
- Device: Computer
- Browser: Chrome
- OS: Windows 11
- Provided sample code: No
- Provided link: No
Maximilian Schulze pro premium priority commented 2 years ago
Procedure: Select 3 images individually and drag them in -> last picture is only uploaded Select 3 images directly and drag them all in -> All images are uploaded