Jump to content

Multiple file uploads


Danny620

Recommended Posts

Hi, I'm building an application that keeps track of stock of cars, I have cars table that contains details about that car but I have a photos table that contains id, car_id, photo.

 

When your on the add a car section I want to be able to upload as many photos as I want but the problem is I'm unsure on how to program it. Do I query the database for the next auto id and then have an Ajax file upload that uploads them and adds to database that next car id? What about if the user decides to cancel half way though? My photos table will be left with reference to that id because it's not yet been added.

 

Can some give me some ideas on how I should go about this?

Link to comment
https://forums.phpfreaks.com/topic/294772-multiple-file-uploads/
Share on other sites

What I'd do is make them create the car entity with the basic details first. Then you know the ID. After initial creation, allow them to upload photos or anything else that needs to be done. Getting the next value of an auto_increment fields is NOT a good idea. What if you have 2 people trying to create a new car entity at the same time before saving? You'd have 2 of the same ID. If you create the car first, you won't have that problem.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.