21,887
社区成员
发帖
与我相关
我的任务
分享
if(file_exists($local_file)){
$file = pathinfo($local_file);
$getFileName = date("ymd").rand(1000,9999);
//$remote_file .= $date("ymd")."/";
$new_file = "{$getFileName}.".$file['extension'];
//创建FTP
$ftp = ftp_connect($ftpUrl) or die("Could not FTP connect");
//登录
ftp_login($ftp,$ftpUser,$ftpPassword);
//模式
ftp_pasv($ftp,$ftpPasv);
//传输
$ftpStatus = ftp_put($ftp,$remote_file.$new_file,$local_file,FTP_BINARY);
if($ftpStatus){
$out['msg'] = $new_file;
}
else{
$out['err'] = '文件上传失败[ftp]';
}
ftp_quit($ftp);
}else{
$out['err'] = $local_file.'未发现上传的文件';