Re[2]: [PHP] uploading a file from a form
| From: | Tom Rogers | Date: | Wed, 30 Jul 2003 01:24:21 +0000 |
| Subject: | Re[2]: [PHP] uploading a file from a form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157474@lists.php.net to get a copy of this message | ||
Hi,
Wednesday, July 30, 2003, 12:09:44 AM, you wrote:
AM> The version is PHP Version 4.2.3.
AM> On Tue, 29 Jul 2003, Tom Rogers wrote:
Then you can use the $_FILES array like this:
if($_FILES["photo"]["error"]==0){ //make sure no errors on upload
if(!empty($_FILES["photo"]["name"])){ //do we have a file name
$tempname = $_FILES["photo"]["tmp_name"]; //this is how php has it
$file = trim($_FILES["photo"]["name"]); //this is what it was called
//clean up the file name
//we don't want something like "this is mac's image.jpg"
$file = ereg_replace("'","",$file);
$file = ereg_replace("%20","_",$file);
$file = ereg_replace(" ","_",$file);
$path = '/home/vencel/www/images/apt'; //this is where we want to store
//make sure that apt has permissions set to 777 so web user
//can write to it
move_uploaded_file($tempname,$file);
}
}
--
regards,
Tom