Error uploading image
From: Adam Rumpke (goldstonrumpke_at_hotmail.com)
Date: 03/29/04
- Next message: Donny D: "Re: eregi question."
- Previous message: The Dude: "Re: "PHP and MySQL Web Development" by Luke Welling and Laura Thomson"
- Next in thread: W. Paulisse: "Re: Error uploading image"
- Reply: W. Paulisse: "Re: Error uploading image"
- Reply:(deleted message) Ian.H: "Re: Error uploading image"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Mar 2004 00:44:44 -0800
Thank those who e-mailed me back on my last question. I am now writing
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
and typed in the right path name but I am confused on why this isnt
working.
HTML FORM
---------
<html>
<head>
<title>Uploading a File</title>
</head>
<body>
<form action="upload_img.php" enctype="multipart/form-data"
method="post">
<input type="file" name="myfile"><br><br>
<input type="submit" value="upload"><br>
</form>
</body>
</html>
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("<b>Error:</b> could not
make directory.");
// copy the file from the temporary upload position to where
you want it
copy($myfile, PATH.$dirname."/".$filename) or
die("<b>Error:</b> could not copy file.");
// delete the temporary uploaded file
unlink($myfile) or die("<b>Error:</b> 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 doesnt work for
me. I keep getting the error message that says "You must select a file
to upload." I did select a file. Seriously, any help would be welcomed
...
- Adam
- Next message: Donny D: "Re: eregi question."
- Previous message: The Dude: "Re: "PHP and MySQL Web Development" by Luke Welling and Laura Thomson"
- Next in thread: W. Paulisse: "Re: Error uploading image"
- Reply: W. Paulisse: "Re: Error uploading image"
- Reply:(deleted message) Ian.H: "Re: Error uploading image"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|