First I asked this question here: How do I change the file name before sending to upload_file.php?
I updated my upload_file.php script with the suggestion, but when I run it, it doesn't work. Using the form from the above link, when I go to upload the script, the echo's seem correct, but when I FTP to the directory the file is supposed to be, the directory is empty? Could someone shine some light on this? I want the file to be uploaded to '/var/www/eedis/fax/uploads/'.
My upload_file.php script looks like this...
<?php
$allowedExts = array("pdf");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ($_FILES["file"]["type"] == "application/pdf")
#&& ($_FILES["file"]["size"] < 20000)
#&& in_array($extension, $allowedExts))
{
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>";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"/var/www/eedis/fax/uploads/" . $_POST['number'] . '.pdf');
}
}
}
else
{
echo "Invalid file";
}
?>