Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Msoft's avatar
Level 1

how to develop 4 images upload and saving system in form in laravel 5.6?

I am working with laravel 5.6 and I am developing auto classified web application. in my app I have a form witch using to save vehicle data. in My form I need upload vehicle images minimum 1 to maximum 4 (user should upload at least 1 image or 4 images). I need this system one by one upload 4 images and need show uploaded images to user before save and need delete button for each images. and after save all data the vehicle images set should save in images column of the vehicle table. please do me some example codes or post me some tutorials links too. it is great help

0 likes
9 replies
davorminchorov's avatar

No, that would be a one to many relationship between vehicles and vehicle_images.

1 like
jlrdw's avatar

Like @Ruffles mentioned you need a one to many or at least separate columns.

There is more to images than just uploaded, you need proper rotation proper image size for mobile vs. Desktop Etc I would seriously consider using a good package for allowing users to upload images.

If it's something in-house only a good program like Adobe Photoshop which I have used in the past to properly rotate and size and optimize images for the web was used.

Sometimes an image will show correctly on one mobile device but flip sideways on another it's very important to get orientation correct.

Msoft's avatar
Level 1

ok well but still I did not find any good tutorials for me develop this type system?

jlrdw's avatar

There has to be at least several pages of previous answers here on image uploading and various packages used. Have you tried a search.

I have posted previous examples and possible packages myself. There's DropZone there's intervention, etc. But there are other packages as well.

Cronix's avatar

You're asking to do a lot, and you're new to this, so it will be complicated if you try to do it all at once. I'd break this up into the simple things, get that working, and then add the more complex stuff on top.

  1. Make a form with 4 file inputs that have the same name, like <input type="file" name="upload[]">
  2. Make the controller that you will send this form to
  3. Create the validation for the files to make sure they are within your criteria (file type, size, max width/height, whatever you require) https://laravel.com/docs/5.6/validation
  4. Loop through your files array in the controller ($request->upload) and save them in the database
  5. redirect back to your form, and show some sort of message (files uploaded successfully, etc)

That right there is a lot of work for someone new, but that is the basics for uploading files. After you get that working, then you can add in the extras like "I need this system one by one upload 4 images and need show uploaded images to user before save and need delete button for each images." Anyway, that's my advice. Don't overwhelm yourself and try to do this all at the same time.

1 like
jlrdw's avatar

Which if you had searched the forum you have seen many Pryor good answers describing just that same stuff with examples even.

I myself have given examples of uploading multiple images and saving to the database.

But again this was in house stuff if you have users uploading images do not do that rather use a good package that can help you with proper image optimization, rotation, and things like that. Otherwise you are going to have a mess on your hands.

You will have badly optimized images images rotated incorrectly a nightmare to fix later.

Feel free not to believe me it will be your headache to fix later not mine.

You ask for tutorials the packages themselves have tutorials, examples and all sorts of stuff right on their websites.

Please or to participate in this conversation.