Form finishes submitting, but file doesn't reach destination
Posted: Thu Dec 31, 2009 2:19 am
I have a php form that I use to send a file to my ftp server. It's supposed to put the file into a folder named uploads. It finishes submitting, but when I check my ftp server, the file isn't there.
Here's the php:
<?php
if (($_FILES["file"]["size"] < 4000000))
{
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("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
When it finishes submitting, it sends me to a page that correctly says this:
Upload: image.jpg
Type: image/jpeg
Size: 25.337890625 Kb
Temp file: /tmp/phpDoM7tw
Stored in: upload/image.jpg
Here's the php:
<?php
if (($_FILES["file"]["size"] < 4000000))
{
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("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
When it finishes submitting, it sends me to a page that correctly says this:
Upload: image.jpg
Type: image/jpeg
Size: 25.337890625 Kb
Temp file: /tmp/phpDoM7tw
Stored in: upload/image.jpg