Danny620 Posted February 21, 2015 Share Posted February 21, 2015 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? Quote Link to comment https://forums.phpfreaks.com/topic/294772-multiple-file-uploads/ Share on other sites More sharing options...
Danny620 Posted February 21, 2015 Author Share Posted February 21, 2015 Anyone Quote Link to comment https://forums.phpfreaks.com/topic/294772-multiple-file-uploads/#findComment-1506341 Share on other sites More sharing options...
scootstah Posted February 21, 2015 Share Posted February 21, 2015 You can process multiple file uploads by making the file input an array. <input type="file" name="files[]" /> <input type="file" name="files[]" />See the manual here: http://php.net/manual/en/features.file-upload.multiple.php Quote Link to comment https://forums.phpfreaks.com/topic/294772-multiple-file-uploads/#findComment-1506362 Share on other sites More sharing options...
Danny620 Posted February 23, 2015 Author Share Posted February 23, 2015 That's not really the answer I was looking for Quote Link to comment https://forums.phpfreaks.com/topic/294772-multiple-file-uploads/#findComment-1506544 Share on other sites More sharing options...
CroNiX Posted February 23, 2015 Share Posted February 23, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/294772-multiple-file-uploads/#findComment-1506545 Share on other sites More sharing options...
Danny620 Posted February 23, 2015 Author Share Posted February 23, 2015 Thanks that's wag till do Quote Link to comment https://forums.phpfreaks.com/topic/294772-multiple-file-uploads/#findComment-1506546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.