简体   繁体   中英

How do I upload images in php after I have already saved data from the form1 and images are uploaded in form2

I have a html page, with a form and image upload, I want to update the database with the images once uploaded, the two form work well individually, but I need to link the form-data to the uploaded images in the database.

kindly help with logic, I am considering using sessions

You can use session as you mentioned or you can updated the relevant record with the next form details.

Say for example, once first form is filled and submited by the user, add those details in database and get the ID of that record. When the second form is submited by the user, update the same record which you have already added for form 1.

So in database you will have only one record for both the forms with all relavent detials.

  • You could save your images in the session if you don't want to save them in the database (which, by the way, might not be a good idea), this avoids putting stuff in the database that is not yet finally processed (as I understand: this happens when the other form is submitted?)

  • You could put them in a table for "temporary images" which are not yet processed finally and just keep track of the IDs through the session

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM