Jump to content

File upload help


atrum

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/105030-file-upload-help/
Share on other sites

Thanks,

 

I acutally figured out the real problem, and that was; the folder upload didn't exist because I was using another name, "teamftp"

 

Now I seem to be running into another issue, and that is that any file I upload has no data.

 

In other words, I uploaded a jpg image. That image is 200kb in size. On the server in the directory it uploaded to the file size shows 0kb. Any ideas on what would be causing that?

Link to comment
https://forums.phpfreaks.com/topic/105030-file-upload-help/#findComment-537745
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.