I've got a script from w3schools.com and the php code is:

  1 <?php
  2 if (($_FILES["file"]["type"] == "image/gif")
  3 || ($_FILES["file"]["type"] == "image/jpeg")
  4 || ($_FILES["file"]["type"] == "image/pjpeg")
  5 && ($_FILES["file"]["size"] < 20000))
  6   {
  7   if ($_FILES["file"]["error"] > 0)
  8     {
  9     echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
10     }
11   else
12     {
13     echo "Upload: " . $_FILES["file"]["name"] . "<br />";
14     echo "Type: " . $_FILES["file"]["type"] . "<br />";
15     echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
16     echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
17
18     if (file_exists("upload/" . $_FILES["file"]["name"]))
19       {
20       echo $_FILES["file"]["name"] . " already exists. ";
21       }
22     else
23       {
24       move_uploaded_file($_FILES["file"]["tmp_name"],
25       "upload/" . $_FILES["file"]["name"]);
26       echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
27       }
28     }
29   }
30 else
31   {
32   echo "Invalid file";
33   }
34 ?>

Is there a way to force it to upload to another directory?

The script and HTML form are in folder:

mydomain.com/private/submit/index.html
mydomain.com/private/submit/upload.php
mydomain.com/private/submit/upload/

I'd like to upload to another directory (re: The private folder is  
password protected, so files there couldn't be viewed by web visitors):

mydomain.com/documents/forms/

Entering that exact URL in the "upload/" on line 25 (above) lets the  
script run fine, but doesn't put the file there.

Any help would be appreciated.

Thanks,
Grant

Reply via email to