Yaratılan dosya için random isim yaratma.

esportaEmre Buğday

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!"; }
?>
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

phpkodlari.com © 2009 Herkes Php öğrenecek
Eglence ve Oyun: Gamikro