2012-10-16 114 views

回答

-1
$file = 'uploaded_img.jpg'; 
$remote_file = 'Saved.txt'; 

ftp_put($conn_id, $remote_file, $file, FTP_ASCII) 

只是改變了遠程文件

2

你將需要做在處理上傳的PHP腳本的名稱變化(我假設你使用PHP的名字,因爲這是uplidfy標準)。這可能有點棘手,因爲您必須將傳入文件名與其擴展名分開。這應該足以讓你開始。

$theFile = $_FILES['file_upl']['name']; 
    $tempFile = $_FILES['file_upl']['tmp_name']; 
    $newName = "newname"; 
    $saveDir = $_SERVER['DOCUMENT_ROOT']."/images/"; 

    //Function returns the extension from the '.' on 
    function get_ext($from_file) { 
     $ext = strtolower(strrchr($from_file,'.')); 
     return $ext; 
    } 

    //This will rename the file to $newname + the extension 
    $theFile = $newname.get_ext($theFile); 

//Save the file 
    move_uploaded_file($tempFile,$saveDir.$theFile);