Jump to content
Danny620

Multiple file uploads

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.