Yaratılan dosya için random isim yaratma.
Merhaba arkadaşlar,
Aşağıda verdiğim kodda html formdan gelen formdaki dosyanın ismiyle aynı şekilde dosyayı ftp ye yüklüyor. Ben asla aynı olmıyacak şekilde random isimler verilmesini istiyorum.
örn: xxx.com/images/h1f3h2 falan gibi.
Kod:
<?php
$target_path = "uploads/"; $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 to the wegaz.com/weepload/uploads/". basename( $_FILES['uploadedfile']['name']). ""; } else{ echo "There was an error uploading the file, please try again!"; }
?>
$target_path = "uploads/"; $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 to the wegaz.com/weepload/uploads/". basename( $_FILES['uploadedfile']['name']). ""; } else{ echo "There was an error uploading the file, please try again!"; }
?>
2013-12-12 18:52:18 Edit:2013-12-12 18:53:32
Php
$uzunluk=20 ; // olusturulacak isimin karakter uzunlugu
function fileNameGeneraTe($uzunluk){
return substr(str_shuffle("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0,$uzunluk);
}
bu isini gorur istersen sayıda ekleyebilirsin
2013-12-14 02:13:42