Description
Can we insert records and upload images into two tables using dropzone from one controller, if so, how? Please give a suitable example.
View Code
Can we insert records and upload images into two tables using dropzone from one controller, if so, how? Please give a suitable example.
Yes, you can insert records into two tables and upload images using Dropzone from one controller in Laravel. Here's a basic example to guide you through the process. In this example, let's assume you have two tables: posts and images.
In js, set the images variable, get them, and pass them to the controller.
foreach ($request->file('images') as $image) {
$imagePath = $image->store('images', 'public');
Image::create([ 'path' => $imagePath]);
Post::create([ 'path' => $imagePath]);
}
That's it :)
0 Likes 0 Comments