function Clear($w){
$w = preg_replace("@[^a-z0-9\öşıüğçİŞĞÜÖÇ ]+@i","",$w);
$tr = array("ı","Ğ","ğ","Ü","ü","Ş","ş","İ","Ö","ö","Ç","ç","&","<",">","+"," ");
$en = array("i","g","g","u","u","s","s","i","o","o","c","c","","","","","-");
$w = str_replace($tr,$en,$w);
return @strtolower($w);
}
function FileDown($url,$isim,$yol){
if(strlen(Clear($isim)) > 25){
$sade = substr(Clear($isim),0,25);
}else{
$sade = Clear($isim);}
$uzanti = strtolower(substr(strrchr($url, "."), 1));
if(strpos($uzanti,"?")){ $bol = explode("?",$uzanti); $uzanti = $bol[0];}
$fullfilename = $sade.'.'.$uzanti;
if(function_exists('curl_init')){
$fp = fopen($yol.$fullfilename,'w+');
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, $url);
curl_setopt($ch , CURLOPT_USERAGENT, 'firefox/2.0.11');
curl_setopt($ch , CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}else{
copy($url,$yol.$fullfilename);}
return $fullfilename;
}

//Kullanımı
$dosya = FileDown('http://site.com/dosya.rar','yeni dosya ismi',"uploads/");



dosyayı uploads klasörü içine indirir