I installed wordpress in a media temple server and noticed that couldn't upload files. After tryng several solutions decided to replicate the problem with a simple script (http://pastie.org/2349720).
<?php
if($_FILES)
print_r($_FILES);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_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 "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("uploads/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else if (!file_exists($_FILES["file"]["tmp_name"]))
{
echo 'temp file doesn\'t exists';
}
else
{
$uploaded=move_uploaded_file($_FILES["file"]["tmp_name"],
$_FILES["file"]["name"]);
if($uploaded)
echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
else
echo "fallo la carga del archivo";
}
}
}
else
{
echo "Invalid file";
}
?>
<html>
<body>
<form action="" 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>
Looks like move_upload_file() is returning false without a warning or error, looked in php documentation and found this
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
I've checked and the file upload doesn't report any errors and the temporary file exist before trying to move it. Already set 777 permission in folder and still not having any luck, any idea on what can be causing this behavior and how to fix it?
thanks.
error_reporting(E_ALL);before your code and look at error/warning given