Hey guys... I have a simple image upload script that allows my visitors to upload one image of their choice... kinda like a profile picture and it makes a thumbnail image and saves all the information in the database (like URL to thumbnail, filename, etc)... but the image is stored outside the database in an uploads folder.
This upload script will see if you currently have a profile pic uploaded, and if so will say:
HERE IS YOUR CURRENT PROFILE PICTURE:
[shows the pic here]
To overwrite the above pic with a new one, attach file below and click submit:
[form]
And the form submits back to itself (same file) and makes the thumb, saves the thumb, inserts info into DB and reloads the current prof pic and form just like above again.
When I upload a picture however, and the page reloads, it "sometimes" still shows the 'OLD' profile picture. But if I reload the page, it will update the current profile picture with the correct, new one. The only thing I can think of that is causing the "HERE IS YOUR CURRENT PROFILE PICTURE" image to stay the same sometimes as the old prof pic, is that right after the MySQL INSERT (where it deletes the old record and inserts the new upload info record) query, it goes into reproducing the above form and calls for the latest record in the DB, but because my php is faster than my DB, it is calling the old record before the new one is created. For my form to display the current image, It calls the database for the new uploaded image record and displays the image if one exists. And this is AFTER the DELETE and INSERT queries take place.
Any help would be greatly appreciated with this matter as I am sure this problem would cause much confusion with a lot of my members. Especially since you can't just click "reload" on a posted form without reposting the data.
Thanks so much.
Upload Image Script... code execution too fast??
Moderator: General Moderators
- seodevhead
- Forum Regular
- Posts: 705
- Joined: Sat Oct 08, 2005 8:18 pm
- Location: Windermere, FL
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
for a hack you could auto refresh the page for everyone, they wouldn't even know with a nodelay header location. Or if you want to slow down the execution maybe something like http://us2.php.net/sleep would do the trick?
- seodevhead
- Forum Regular
- Posts: 705
- Joined: Sat Oct 08, 2005 8:18 pm
- Location: Windermere, FL