View Full Version : file upload

03-08-2007, 12:15 AM
I am using this code to allow a user to upload a file.

$target_path = "upload/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
//echo "The file ". basename( $_FILES['uploadedfile']['name']). "has been uploaded";
//echo "There was an error uploading the file, please try again!";

What i want to do is change the name of the file they upload.How do i upload the file and then change it's name?


03-08-2007, 02:33 AM
It's the second parameter of the move_uploaded_file() (http://us3.php.net/manual/en/function.move-uploaded-file.php) function which you are already using so just change the second parameter.

03-08-2007, 05:15 AM
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
Change it here ^

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum