Created
December 2, 2013 20:20
-
-
Save PintuKumarPal/7758097 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//****** Function for generate random character *****************************/ | |
function randomGenerator($strlength) | |
{ | |
$str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
$strshuf=str_shuffle($str); | |
$start=rand(0,strlen($str) - $strlength); | |
return substr(str_shuffle($strshuf),$start,$strlength); | |
} | |
$path_thumbs = "x:/projectname/uploads/"; //Upload Path | |
$uploadfilename = "Attachfile"; //File name submitted by form | |
$code = randomGenerator(5); //Generate random character | |
$fileParts = pathinfo($_FILES[$uploadfilename]['name']); | |
$file_name_only = stripslashes($fileParts['filename']); | |
$extension = $fileParts['extension']; | |
$UploadFileName = $file_name_only."_".$code.".$extension"; //Make a new file name | |
move_uploaded_file($_FILES[$formname]["tmp_name"],$path_thumbs.$UploadFileName); //upload file | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment