1
votes

I am using PHP 7.0.9 with IIS 8. I have a html form to upload an image. The method is POST, the action is correct, and enctype is "multipart/form-data". However, when I submit the form, the page hangs, as if it was trying to upload the selected file endlessly - it weight about 30kb, not a big deal...

Here is my form :

<!DOCTYPE html>
<html>
<body>

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="text" name="textInput" id="textInput">
    <input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>

And here is upload.php :

<?php

echo "ok<br/>";
var_dump($_POST);

?>

As is, when I click on "Upload Image", the page hangs as if it was uploading the file endlessly.

But if I remove the enctype or if I change the action by get, the form is submited and prints :

ok
array(0) { }

The $_POST array is obviously empty, but why doesn't it works with enctype="multipart/form-data" ?

FYI:

file_uploads = On
upload_max_filesize = 20M
max_file_uploads = 20
upload_tmp_dir = C:\Windows\temp

...and C:\Windows\temp is writeable for Everyone. Yes, the group Everyone - I am really annoyed by this, and I don't want any rights problem.

Some tests later...

If I use :

<form action="upload.php" method="get" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="text" name="textInput" id="textInput">
    <input type="submit" value="Upload Image" name="submit">
</form>

The result is :

ok
array(3) { ["fileToUpload"]=> string(13) "imageName.png" ["textInput"]=> string(4) "blah" ["submit"]=> string(12) "Upload Image" }

It seems to be a problem between the method and the enctype.

EDIT

For what it worth, I think it's definitly a IIS problem: when I look in the IIS log I see the request for the form :

2017-01-16 13:28:19 X.X.X.X GET /testupload.html - 80 - X.X.X.X Mozilla/5.0+(Windows+NT+6.2;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/55.0.2883.87+Safari/537.36 - 304 0 0 1140

But nothing is written when I submit the form; so I don't even know if IIS is receiving the request.

3
Have you tried with a different browser? Does it work with input type text only if you ommit the input type file? - Blackbam
I cannot replicate it with the same php version, but with Apache instead of IIS. - Blaatpraat
@Blackbam I tried it with Chrome 55 and Internet Explorer 10. - gobes
Whats actually happening - are the browsers just freezing? Have you checked permissions for upload directory? Maybe the file cannot be moved there (if form submission with text only works?) ? - Blackbam
@Blaatpraat The code can't be simplier; I am pretty sure the problem is coming from some IIS misconfiguration... - gobes

3 Answers

0
votes

Finally, the culprit was Glimpse. I absolutely don't know why, but once I had removed every traces of the plugin in the web.config, upload via PHP worked again.

-1
votes

"I cannot replicate it with the same php version, but with Apache instead of IIS"

Take a look on your IIS firewall.

-1
votes

use $_FILES (for files) instead of $_POST