Firefox Upload Form Issue
Asked Answered
M

7

3

I've created an upload script in php that takes a file, resizes it, and creates a cropped square thumbnail. The script itself seems to work fine.

However, when I tried to upload an image through Firefox, on clicking the submit button the browser shows the loading animation, but it never calls the script, it just stays on the current page. If don’t upload an image, then the script can be found and is run.

I tried in safari, and I don’t get the same problem, I can upload an image from the form, it will process it and take me the correct page.

I’ve tired just calling a basic script from the form, it just prints out the $_POST and $_FILES, and I get the same result, if an image is present, it won’t get to the script, if no image is present, it runs fine.

I’m just wondering if anyone has any idea what’s going on?


=Update=

Okay, so I’ve still got this problem, I seem to think I’ve found out what’s causing it then, but then I find something that contradicts it completely.

At the moment, I’ve noticed that I can successfully upload after I clear my Firefox cache, but I can only upload one image, then when I try to upload another, I can’t, it just resets the connection after "Loading..." for a bit.

Also, I’ve noticed that I can Ctrl+F5 a few times and get another upload through.

Although there are ways around this, I don’t want to have a form that requires users to clear cookies or refresh every time they need to upload. And as I’ve mentioned before, this error does not occur in IE/Opera/Safari/Chrome.

It seems like Firefox is storing something, I’m not sure what. Any help would be gratefully appreciated.

If it helps here is the code I’m using.

The HTML Form

<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
<label for="file">Choose a file to upload</label>
<input id="file" name="file" type="file" /><br />
<input type="submit" value="Upload File" name="submit" />

And the PHP:

if (isset($_POST['submit'])) {

  echo "Processing...<br/>";

  if (isset($_FILES['file']['name'])) {
      $file_array = $_FILES['file'];

      echo "Uploading...";
      upload File($file_array);
      echo "...Done";

  }
}

The echos are for me to see what’s going on. If none of them are actually being output. So for some reason the form is not being submitted. Which is why it’s not getting to the script. I’ve no idea why though. I’ve got no CSS, or JavaScript errors.

== Update ==

Okay I’ve being trying some more things and still no luck, the HTML, CSS and JavaScript is all valid. I’ve done an IIS Reset, I’ve recreated my Firefox profile. And still now luck.

I was testing it again, and this time I stopped it in the middle of loading (before the connection was reset) and then tried to go to a different page of the website, and the freezing continued, it would still say "Loading..." and "Waiting for localhost...". Not really sure what to make of that, is it some settings that I have? But then why doesn’t it affect other browsers?

== Update ==

As I mentioned below, it seems that AVG Linkscanner/Active surf shield seems to causing this issue, and there are many reports of others having similar problems with it. I updated from AVG Free v9.0.733 to v9.0.790 and I STILL have the same problem. I’m going to browse the AVG support forums and maybe post something over there since it seems to be an AVG issue.

If anyone does have any more insight, please post below. It’s much appreciated :)

Manus answered 27/2, 2010 at 15:34 Comment(13)
Please post the script if you'd like us to look at it.Unsuitable
Thats the thing, its not even calling the script full stop. Even if i set the form to send data to a simple script like i mentioned above, it wont.Manus
Hit CTRL+SHIFT+J to open the Firefox console and check for any error messages?Syncom
Still no luck, ive checked the console for errors, a few js errors but even without including the js i get the same problem. Upload works as it should in IE, Safari, Opera and Chrome.Manus
Ive even tried just posting to a script that echos "hello". And once again, if i send an image, it wont go anywhere. :(Manus
So does it work as expected with a text file? Try using Firebug to see if there is any request made to an URL when submittingArrowworm
Same thing with text files, might get the odd one through but more often than not the connection gets reset. Also firebug shows nothing.Manus
I m no (X)HTML guru but you can try removing the xhtml strictness (declaration) and just use "normal" html. If it calls your php script, so it may be because of your xhtml not being valid - Just an ideaArrowworm
yeah same problem with an id for the form there too.Manus
Are you still experiencing the problem? You seemed to have narrowed it down to AVG LinkScanner. A Google search on that brings up upload problems on sites like Flickr and YouTube too, in any case. They may have released an update to AVG9 2 days ago that fixes the issue: forums.avg.com/cz-en/…Thremmatology
Thanks for the link, i hadnt come across that thread, altough i had found others. I tried an avg update about 3 or 4 days ago and was tol it was up to date, so i'll try update again. Edit: Im running AVG Free v9.0.733 and there seems to be no later release at present.Manus
Found AVG Free v9.0.790 which avg claim fixes the problem, although the standard download on their site points to v9.0.730. I'll download and post the result.Manus
Have you tried encoding instead of enctype? There are issues with FF and IE. I use both now.Flag
M
2

Okay, im getting somewhere with this, you may think this is just a stupid mistake but read on.

If i dont have the < html >< body >..etc tags and just have..

<form enctype="multipart/form-data" action="up.php" method="POST">
    <label for="file">Choose a file to upload</label>
    <input id="file" name="file" type="file" /><br />
    <input type="submit" value="Upload File" name="submit" />
</form>

Then i get this issue, where firefox will hang, on form submission.

If i have the correct tags like..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 


<head>
<title></title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body >

    <form enctype="multipart/form-data" action="up.php" method="POST">
    <label for="file">Choose a file to upload</label>
    <input id="file" name="file" type="file" /><br />
    <input type="submit" value="Upload File" name="submit" />
    </form>

</body>

</html>

Then it seems that this works. Now this looks simple, but i build my pages up dynamically so i just have one file that contains just the form code that gets included in the page.

Thats as far as ive got, althought having the form code in a separate file should make no difference since its all put together server side.

Manus answered 28/2, 2010 at 21:25 Comment(1)
lol I was faced with this problem like 1 day, I just realized that my problem was Firefox, since in Chrome the upload works and I can see the progress at the bottom right. I was wondering is there any addon that shows a progress bar for the uploads for firefox.Gyatt
O
0

Sometimes, relative paths are perceived differently by different browsers, not that sure actually but try to specify current directory by prefixing path with ./, eg:

$target_path = "./public/photos/";

Rest of the code looks fine to me.

Ocampo answered 27/2, 2010 at 18:47 Comment(3)
Thanks for the help, but the process isnt even getting this far. I made the change anyway, and tested bu no luck. im calling it from localhost/upload/index.php the form has been set to send data to upload.php in the same directory. If there is an image selected, when i click submit, it just hangs on index.php with the loading animation goin round. Ive no idea why.Manus
@cast01: make sure that you have write permission to the directory chmod to 755Ocampo
Thanks again, but still no luck. Im completley stumped.Manus
R
0

Just in case you are using the latest FF 3.6 I'm experiencing exactly the same problem, Any form loading a big file (1MB it's enought) seem to block FF upload. On IE7/Safari/Opera it works.

Reinsure answered 28/2, 2010 at 11:6 Comment(1)
Hey, thanks, initially i thought it might be my version of FF but im still using 3.5, and the uploads vary, most are only 200-300KB.Manus
H
0

Then when you right click in FF and view source, it should look exactly like it does in your code above (below "If i have the correct tags like..").

Hinayana answered 8/3, 2010 at 16:47 Comment(2)
yeah, all looks fine in the page source. Page is constructed correctly.Manus
if you want you can post it, just to make sure.Hinayana
A
0

From the xhtml 1.0 specification

HTML 4 defined the name attribute for the elements a, applet, form, frame, iframe, img, and map. HTML 4 also introduced the id attribute. Both of these attributes are designed to be used as fragment identifiers.

In XML, fragment identifiers are of type ID, and there can only be a single attribute of type ID per element. Therefore, in XHTML 1.0 the id attribute is defined to be of type ID. In order to ensure that XHTML 1.0 documents are well-structured XML documents, XHTML 1.0 documents MUST use the id attribute when defining fragment identifiers on the elements listed above.

Maybe adding an id to the form could fix your problem.

Arrowworm answered 9/3, 2010 at 17:40 Comment(15)
hi there, i took ur advice and added an id="myform" to the form tag, and still i get the same behaviour. I think it could still be the validation though, as ive messed around with different doc types, at one point i had it as transitional, and the problem happened more often. (I dont know if they are related issues or just a coincedence at this stage however.Manus
As I said above(in the OP), try with a "standard" html without being xhtml compliant and see if it fires your php scriptArrowworm
Okay, well ive changed doctype to transitional, ran it through the validator and its valid, also my web developers toolbar is showing no html/css/js errors. The problem seems to be happening less often, but not less enough for me to discount it.Manus
Just seen your comment, ill try standard now :)Manus
Ive tried standard, using <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "w3.org/TR/html4/strict.dtd"> and getting pretty much the same thingManus
Try adding some javascript onSubmit with an alert to see if the submit button actually triggers something.Arrowworm
Ahh, i added the javascript, and the form seems to be submitted. i added 'onSubmit="alert('submitted')"' and this alert is displayed, even when the script isnt called. I cant think why this is happeneing though. Its getting stuck somewhere in the middle.Manus
Ive also logged values to the firebug console, and input seems to be picked up correctly.Manus
One more test: Instead of using echo $_SERVER["PHP_SELF"]; to generate dynamically the action in your form, can you hardcode the name of the target php script and try it again? If it doesnt work, you will just have to hire an exorcist to kill the daemon inside your workstation :)Arrowworm
once again no luck, i have absolultey no idea whats causing this. Thanks for the suggestions though, much appretiated! :)Manus
Another idea, change the method from "post" to "get" and see if it calls the php script. I find this problem weird .. and interesting :)Arrowworm
Nice idea, i tried it, and the from is called, although the iamge just isnt passed. I think i mave have found the daemon in my workstation....AVG Linkscanner. I disabled it and uploads seem to be getting through. However i dont want to have to disable it, or tell users to disable it to upload files.Manus
Maybe using a post via ajax can bypass AVG Linkscanner.Arrowworm
Yeah ill give that a try, and once again, thanks for the help :) Its a shame though, since i want to have graceful degradation and if the non js users have to start disabling things for successful uploads its bit messyManus
I have use this link validator.w3.org to check your xhtml in your OP and it reports some errors. Give it a try, if there are some errors, fix them and see. One of the error was to have the "post" method in lowercaseArrowworm
A
0

Maybe shomething wrong with if (isset($_POST['submit'])) { and the variable $_POST['submit'] is not included by FireFox?

<pre>
    <?PHP
        print_r($_POST);
    ?>
</pre>
Arleanarlee answered 15/3, 2010 at 1:14 Comment(1)
nice idea, but ive alreadt done a print_r on the $_POST values. In the cases that frirefox doesnt reset the connection, they are printed out correctly. However when it does reset, the script doesnt even get that far to see whats actually being posted. The form is submitted but its hanging in between.Manus
B
0

This isn't going to help you much but I am having EXACTLY the same problem. I have even re-installed FF, cleared cache, stripped the code right down (to a very simple form without validation and with all PHP stripped out - both on load and on post back). I have the problem in FF 3.6.13 and have tested against current versions of Safari(win), Chrome, Opera and IE where the code all works perfectly. My code validates as strict XHTML and all the suggestions above are already in there... what's more I am using my local (on the same computer) web site.

MANY thanks for pointing me towards AVG Link scanner... disabling it does fix the problem but that still leaves me thinking FF has a bug as "all" other browsers play nicely with the AVG Link scanner on.

Bauxite answered 6/2, 2011 at 17:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.