0
我使用uploadifive上传图片 - 但是我想将图片的名称更改为“newimage”我不确定在哪里或如何做到这一点 - 这是最后一个我需要部署的修改。uploadifive - 更改上传文件的名称
我使用uploadifive上传图片 - 但是我想将图片的名称更改为“newimage”我不确定在哪里或如何做到这一点 - 这是最后一个我需要部署的修改。uploadifive - 更改上传文件的名称
$file = 'uploaded_img.jpg';
$remote_file = 'Saved.txt';
ftp_put($conn_id, $remote_file, $file, FTP_ASCII)
只是改变了远程文件
你将需要做在处理上传的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);