You must select a file to upload -> Error :(

They have: 4 posts

Joined: Mar 2004

Thank those who e-mailed me back on my last question. Now, I am trying my 2nd project. I have attempted to write a script from a tutorial I found at "HotScripts" ... I am trying to upload an image from html form to apache. I chmod(ed) the directory on my Linux server and I have typed in the right path names ... BUT I am confused on why this isnt
working.

HTML FORM
---------

Uploading a File

PHP HANDLER
------------
<?

// name of the directory that your uploads will be kept in
$dirname = "images";

// the path that the uploads directory will be placed in
define(PATH, "/var/www/html/building/images/");

// gets just the file name and extension from the file input
// in the form
$filename = $myfile_name;

// check if they actually placed something in the file input
if ($filename != "")
{
// check if the directory exists
// if it doesnt exist, make the directory
if (!$dir = @opendir(PATH.$dirname))
// make the directory (sets chmod to 700)
mkdir(PATH.$dirname, 0700) or die("Error: could not
make directory.");

// copy the file from the temporary upload position to where
you want it
copy($myfile, PATH.$dirname."/".$filename) or
die("Error: could not copy file.");

// delete the temporary uploaded file
unlink($myfile) or die("Error: could not delete
uploaded file.");

// tell them it worked
echo "File uploaded successfully.";
}
else
{
// tell them to browse for a file
echo "You must select a file to upload.";
}

?>

I am still learning and I cant see why this tutorial code doesnt work when I try to run it. I keep getting the error message that says "You must select a file to upload." BUT -> I did select a file.

Seriously, any help would be welcomed
...

- Adam

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

url?

They have: 4 posts

Joined: Mar 2004

Oh, about the URL ... I am building on my home pc and when I have it finished I will put it on my server. Right now it is using localhost at home

He has: 1,380 posts

Joined: Feb 2002

Dude...remember that I mentioned the [php] [html] and [code] tags?

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.