note 105032 deleted from function.rename by danbrown

From: Date: Mon, 25 Jul 2011 12:27:49 +0000
Subject: note 105032 deleted from function.rename by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181832@lists.php.net to get a copy of this message
Note Submitter: ojhasubrat35 at gmail dot com Reason: 2 ---- <?php /* A good way to rename a file before uploading it */ /* This is to set the target directory where the file will be uploaded */ $t_path="uploads/"; //to get the name of the file $fname=basename($_FILES['upload']['name']); $array=explode(".",$fname,2); //to get the proper extension of the file $ext=".".$array[1]; //To get the random no $rfile=rand(100000,10000000); //To get the new name with proper extension $nfile=$rfile.$ext; //to get the path where the file will be uploaded $t_path=$t_path.$nfile; //This function checks if file is uploaded or not if(move_uploaded_file($_FILES['upload']['tmp_name'],$t_path)) echo "You have successfully uploaded"; else echo "Some problem there"; ?>

« previous php.notes (#181832) next »