I try to implement an uploading form but I can't get data from $HTTP_POST_FILES array.

My form looks like:

<form enctype="multipart/form-data" name="subscribe" method="POST" action="subscribe.php">
<input type="file" name="sub_picture">
........
</form>

When I'm in my script, I could access all $HTTP_POST_VARS elements without any problem.

When I access $HTTP_POST_FILES, $HTTP_POST_FILES['subpicture']['name'], etc. I get nothing.

When I access $sub_picture_name, $sub_picture_size, still nothing.

When I access $HTTP_POST_VARS["sub_picture"], I get "C", which I guess is the beginning of my mime-type.

Did my file upload? It is a server issue? I need some help!

    Side note: At first I saw the variable upload_tmp_dir was commented in php.ini. Nothing works.

    I simply removed the comment, because then my upload dir should be my OS working directory. Still, my $HTTP_POST_FILES don't work.

      Try to name the file field something 'without' an underscore.

      It was reported a while ago that some browsers, and php mixtures would give unfriendly results when dealing with a virable name with an underscore when it was regarding a file upload through a form.

      So, try to rename it all to "subpicture" instead of "sub_picture"...

      Worth a try.

      Other than that, those vars "subpicture" "subpicture_name" "subpicture_size" should exist if you had selected a file to upload. Sometimes "subpicture_size" will be null, depending on the browser, so its very unreliable... best to use a filesize function on the actual file that you copy from temp upload dir to the final resting place.

        I still have the same problem when I rename my field "subpicture". I go to search for more info, and I post the answer to the problem if I find.

        Thanks for your support!

          If anyone wants to help me, this may help:

          global $subpicture_name;
          global $HTTP_POST_VARS;
          global $HTTP_POST_FILES;

          echo("variable subpicture_name: ".$subpicture_name."<br/>"); (Output is none)
          echo("Post files: ".$HTTP_POST_FILES["subpicture"]."<br/>"); (Output is none)
          echo("Post name: ".$HTTP_POST_FILES["subpicture"]["name"]."<br/>"); (Output is none)
          echo("Var post : ".$HTTP_POST_VARS["subpicture"]."<br/>"); (Output is: "Content-Type: image/jpeg; name=\"10310193536.jpg\"ÿØÿà")

            Thanks a lot for your help, I found my problem!

            I am using Opera, and it seems like there is a bug with this Browser with multiple/form-data enctype.

            I was really surprised to see my upload working under Netscape but not under Opera! hehehe!

              Ah... yesssss... If I had known, I could've mentioned that ;-)

              I took for granted of "who would use opera?" so I didn't mention it, hehehe.

              This goes for many versions of iCab as well... I am unsure about the LATEST version of iCab if it uploads files correctly or not, but every version I have tried before sends the data in a format that PHP doesnt like (as well as some other scripting languages). Opera is a really bad one... it would rearrange data placement in the POST data, and well, thats a BIG FAT NO-NO when every scripting language is designed to expect data to be where it should be in a multipart POST data chunk ;-) Why the programmers of opera decided to screw with it... who knows. All I know is, it has made a few of my sites unusable by opera users, so I just give those users a big fat dialog box saying (in so many words) "Your browser is broken, go away!" ;-)

              Glad you found out the problem.

                Hehehe!

                You are really rude against Opera! Personaly, I like this software! I just can't believe they messed up with form data!

                Do you know any resources about browser capabilities, bugs, etc? I know resources about HTML interpretation, but not about bugs like the form data bug in Opera.

                  Write a Reply...