note 105032 added to function.rename

From: Date: Sat, 23 Jul 2011 07:03:39 +0000
Subject: note 105032 added to function.rename
Groups: php.notes 
Request: Send a blank email to php-notes+get-181802@lists.php.net to get a copy of this message
<?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"; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 117.226.136.88 ---- Manual Page -- http://www.php.net/manual/en/function.rename.php Edit -- https://master.php.net/note/edit/105032 Del: integrated -- https://master.php.net/note/delete/105032/integrated Del: useless -- https://master.php.net/note/delete/105032/useless Del: bad code -- https://master.php.net/note/delete/105032/bad+code Del: spam -- https://master.php.net/note/delete/105032/spam Del: non-english -- https://master.php.net/note/delete/105032/non-english Del: in docs -- https://master.php.net/note/delete/105032/in+docs Del: other reasons-- https://master.php.net/note/delete/105032 Reject -- https://master.php.net/note/reject/105032 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181802) next »