Hello all,
I am still new to php, and I am trying to get an file upload script to work.
I am using the example found on w3schools.com, and everything appears to work on the front end, but when I browse to the upload directory on my server, I do not see the file that was just uploaded. I just need some help to try and figure out why.
Here is the Html form.
<html>
<body><form action="upload_file.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>
And the php code
<?php
if ($_FILES["file"]["size"] < 20000)
{
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("teamftp/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "teamftp/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
The output on the browser suggests that every thing works, but as I stated above, the file never gets loaded to the server.
Also just some additional information on my server.
I run
apache 2.0
php 5.0
Freebsd 6.4
Directory to upload is chmoded to 777 for testing.
any help you can give would be greatly appreciated.