-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle multiple file inputs with addMediaFromRequest? #227
Comments
When uploading multiple files with the same name in the request, do not use Get the files of the request and add them manually. Try this: foreach($request->file('images') as $image) {
$report->addMedia($image)->toCollection('medical-reports');
} Reopen if you are still having problems. |
I was looking for the same answer for Laravel Medialibrary v.7 here. The following code works for me. foreach($request->file('images') as $image) {
$report->addMedia($image)->toMediaCollection('medical-reports');
} I only need to change toCollection() to toMediaCollection(). Thanks @kickthemooon and @freekmurze. |
@freekmurze how can I show these media in list view page? |
try to add it to specific media collection then use |
@theinhlamaw it's slow the server whene using foreach |
You can also try this
|
good way to upload multiple media this response returned |
So the addMediaFromRequest expects the request key
in my case the request key is images[] so it is an array of files
after which the key becomes and integer.
so $request->file('images') returns this:
when i do this
i get this error
and when I do this
I get this error
Which is the true, the request does not have any key names by the tmp upload path of the file
Now I am not sure how to feed the addMediaFromRequest method...
The text was updated successfully, but these errors were encountered: