Re: Form with browse for file to upload "ftp"
| From: | Nathan Taylor | Date: | Sat, 22 Nov 2003 19:20:18 +0000 |
| Subject: | Re: Form with browse for file to upload "ftp" | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170678@lists.php.net to get a copy of this message | ||
There is nothing special to be done with the form itself for it to support file uploading aside from
supply a browse field:
<input type="file" name="file">
As for uploading it, here's some untested code:
if(!empty($_FILES['file']['tmp_name'])) {
$name = strtolower(eregi_replace('#| |\?|!', '',
$_FILES['file']['name']));
$destination = 'path/to/where/you/want/the/file/saved/'.$name;
if(move_uploaded_file($_FILES['file']['tmp_name'], $destination)) {
echo 'Successful';
} else {
echo 'Failed';
}
}
----- Original Message -----
From: PAUL FERRIE
To: php-general@lists.php.net
Sent: Saturday, November 22, 2003 2:04 PM
Subject: [PHP] Form with browse for file to upload "ftp"
Getting bit of a regular on here :)
I am hoping that someone can point me to a script that allows me to attach a
file to be uploaded to a set dir.
I have already got the form built, except for a browse file option.
The form is part of this admin area
http://thor.ancilenetworks.co.uk/~pferrie/vinrev/adm/myadmin.html
Instead of having a textfield displaying a url of the image and the admin
having to upload it sepratly i thought that i could get the admin to upload
the image via the form. keeps it altogether.
I wouldnt know were to begin adding this to the form. i am pretty sure
there a pre-built script that can do this. Can someone point me to one. i
had a quick look but came up with very little.
Cheers
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php