I'm trying to debug an issue with a WordPress 3.5.1 where I cannot upload media via HTTP at all; the media uploader simply says "HTTP error" and fails. To diagnose what's going on, I decided to write (i.e. copy from w3schools) a really basic PHP file uploader to see if there's something weird going on behind the scenes. But for some reason, the $_FILE
structure doesn't contain any information at all, even in the most basic of examples:
file.php :
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
upload.php :
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?>
In every browser I've tried, with every file I've tried, this just outputs:
Upload:
Type:
Size: 0 kB
Stored in:
and printing $_FILES
shows that it is just an empty array.
I'm using PHP-5
on shared hosting (lunarpages), but the php.ini
file has file_uploads
on and the size of the files I tried is nowhere even close to the upload_max_filesize
. I am ready to throw my laptop against a wall, so any help would save me a couple thousand dollars.
<?php error_reporting_(E_ALL); ini_set('display_errors', true); print_r($_FILES); ?>
in the script? – DanFromGermany Jun 13 '13 at 21:28ini_set
commands won't do anything. – Don Rhummy Jun 13 '13 at 22:04