dezkit Posted September 27, 2008 Share Posted September 27, 2008 Hi how do i do so that the file name will be random, instead of what it is uploaded as? <?php $path= "uploads/".$HTTP_POST_FILES['ufile']['name']; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "File Upload has been successful.<BR/><BR/>"; echo "<table border=0>"; echo "<tr><td>"; echo "File Name: "; echo "<td>"; echo $HTTP_POST_FILES['ufile']['name']; echo "<tr><td>"; echo "File Size: "; echo "<td>"; echo $HTTP_POST_FILES['ufile']['size']; echo "<tr><td>"; echo "File Type: "; echo "<td>"; echo $HTTP_POST_FILES['ufile']['type']; echo "</table>"; echo "<BR/>Click <a href=\"$path\">here</a> to view the uploaded file."; } else { echo "Error"; } } ?> thanks so much Quote Link to comment https://forums.phpfreaks.com/topic/126094-solved-php-upload/ Share on other sites More sharing options...
dezkit Posted September 27, 2008 Author Share Posted September 27, 2008 Uhhhh, bump? Quote Link to comment https://forums.phpfreaks.com/topic/126094-solved-php-upload/#findComment-652043 Share on other sites More sharing options...
dezkit Posted September 27, 2008 Author Share Posted September 27, 2008 Topic solved, made my own script <?php function findexts($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } global $string; $pattern = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; if(empty($length)){ $length = "10"; } for($i=0; $i<$length; $i++){ $string .= $pattern{rand(0,61)}; } $ext = findexts($_FILES['ufile']['name']); $path= "uploads/$string.$ext"; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "File Upload has been successful.<BR/><BR/>"; echo "<table border=0>"; echo "<tr><td>"; echo "File Name: "; echo "<td>"; echo "$string.$ext"; echo "<tr><td>"; echo "File Size: "; echo "<td>"; echo $HTTP_POST_FILES['ufile']['size']; echo "<tr><td>"; echo "File Type: "; echo "<td>"; echo $HTTP_POST_FILES['ufile']['type']; echo "</table>"; echo "<BR/>Click <a href=\"$path\">here</a> to view the uploaded file."; } else { echo "Error"; } } ?> Rate it 1 through 10 guys! Quote Link to comment https://forums.phpfreaks.com/topic/126094-solved-php-upload/#findComment-652045 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.