Form with image upload stalls after repeated submits

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
fluvly
Forum Newbie
Posts: 10
Joined: Wed Sep 23, 2009 10:08 am

Form with image upload stalls after repeated submits

Post by fluvly »

I have a simple form which uploads a picture and updates different text fields onto a database. Everything is run locally, I haven't tried it on a real server yet. It looks like this:

Code: Select all

 
 
<form action="" method="post" enctype="multipart/form-data">
<label>Name</label> <input name="name" value="randname"/>
<label>Intro</label> <textarea name="intro">Intro</textarea>
<label>Main</label> <textarea name="main">Main</textarea>
<img src="image.jpg" />
<input type="file" name="image">
<input name="submit" type="submit" value="Submit" />
<input name="submitted_edit" type="hidden" value="TRUE" />
</form>
 
 
The database is then updated with the text fields, the image is copied to a separate folder and its path is written in the database.

When I press the Submit button, the form reloads the same page over and over again, and if I change any of the text fields, each time they get updated on the database correctly.

However, it does not work as spotlessly if, each time, I change the image field by selecting a new photo: when I press the Submit button over and over again, sometimes the page stalls, it doesn't go through and I can see in the status bar the text "contacting localhost". This happens totally randomly; sometimes the form goes through, the image path gets copied and updated, and the page reloads fine. Other times, as I already said, it stalls, and only by pressing the Submit button a second time I manage to make the form reload the page and do what it's supposed to do. It doesn't depend on the picture, since it happens also when I change the existing picture to the same picture: sometimes it works fine at the first try, other times it takes 2 clicks of the submit button to go through.

Do any of you have any idea of what could cause this behaviour? It's driving me insane. Maybe the error is written to a log somewhere? Thanks in advance for any help.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Form with image upload stalls after repeated submits

Post by jackpf »

Are you using internet explorer?

And yeah, you could check your logs. See if there's anything unusual. They're in the "logs" dir in the apache install dir btw.
Post Reply