RE: [PHP] Uploading Files
| From: | Rich Gray | Date: | Tue, 24 Feb 2004 23:11:32 +0000 |
| Subject: | RE: [PHP] Uploading Files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-178784@lists.php.net to get a copy of this message | ||
> <?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