Re: Uploading Files
| From: | Tom Wollaston | Date: | Wed, 25 Feb 2004 00:13:53 +0000 |
| Subject: | Re: Uploading Files | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-178793@lists.php.net to get a copy of this message | ||
I have updated my script as follows but it still doesn't seem to work:
<?php
$uploadpath = "/home/sites/site176/web/makeit";
if($userfile) {
move_uploaded_file ($_FILES ['userfile'], "$uploadpath/$userfile_name");
echo $userfile_name;
echo "Successfully Added!<br>\n";
//$username : contains the name of TMP file, $usrfile_name : it's the real
name of file
}
?>
<form enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>"
method="post" name="upload">
File to Upload: <input type=file name=userfile><BR>
<input type=submit value="Upload">
</form>
I get the message that the file has been successfully added, but when I
check the location the file doesn't exsit.
Any more ideas??
Tom
"Rich Gray" <rich@f1central.net> wrote in message
news:EDEGIPFFGBJHCIJCMPKOKEPMHHAA.rich@f1central.net...
> > <?php
> > if($userfile) {
> > copy($userfile, '/home/sites/site176/web/makeit/$userfile_name');
> > echo "Successfully Added!<br>\n";
> > }
> > ?>
> > <form action="<?php echo $PHP_SELF ?>" method="post"
> > name="upload">
> > File to Upload: <input type=file name=userfile><BR>
> > <input type=submit value="Upload">
> > </form>
>
> Hi Tom
>
> Here's some quick comments..
>
> . You need enctype="multipart/form-data" on your form for file uploads
> . Watch out for max file size being exceeded -- check the php manual on
> 'Handling file uploads'
> . If register_globals is off on your server you'd better start looking at
> using the $_FILES superglobal (check the manual)
> . use move_uploaded_file(...) rather than copy(...)
>
> HTH
> Rich