tags:

views:

38

answers:

2

Here is what i'm trying to do:

I have a form with few text fields and image upload via JavaScript(to have that loading animation).

here is the link http://netfecs.com/inprogress/phat_cat/admin_edit_car.php?id=4

I'm using row id as part of the image name in the database.

What is a good way to set the id and retrieve if before submitting the form because while user is filling out the form the images are being uploaded and they need an id.

Any Thoughts?

A: 

I see two ways:

  1. Make an AJAX/JSON call and create the record, returning the id
  2. Create an empty record before displaying the form and use its id in the form
Sonny
+2  A: 

The best solution for you would be to have all the images uploaded stored in a temp location. Store that location in a session. Once the user submits the form, add the data into the database then move all the files in the session to a perm location and write to the database as needed.

MANCHUCK
do you know how long can the file stay in the temp folder
Ross
Depends on your system set up. You would need to check with your admin for the file. As far as how long it stays in the PHP session, that is based off the session.cookie_lifetime param in your ini file. a value of 0 means: until the browser is closedhttp://us3.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
MANCHUCK