Jump to content

[SOLVED] Form with image upload stalls after repeated submits


Recommended Posts

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:


<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.

Maybe the page is loading sometimes a longer time and when you press again the submit it gets loaded and submitted faster? Maybe something in your code is causing this or maybe there is something wrong with your local web server. In case it is caused by error, you could try looking into your php's and your web server's error logs and see if there is anything.

That's right, I wouldn't dream of changing its location.  :D

 

There's nothing in the error logs referring to what happens when it stalls - however, I have just tried using Firefox instead of Safari, and everything runs smoothly there. So I'll just wait until I upload everything to the server, and test it there.

 

Thanks for all the help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.