windows系统php使用ftp上传阿里云服务器,提示No such file or directory,上传其他服务器没问题,阿里云ip访问已经设置了,有哪位大神知道如何处理,下面是代码
function FTPuploads()
{
$file = "D:/2019032157946.jpeg";
$ftp = C('FTP_CONFIG');
$remote_file = $ftp['ftp_trmote_file'];
//链接确认
$conn_id = ftp_connect(trim($ftp['ftp_server']));
ftp_pasv($conn_id, true);
if (!$conn_id) {
//连接失败
echo 'connect fail';
die();
}
//登录
$login_result = ftp_login($conn_id, trim($ftp['ftp_user_name']), trim($ftp['ftp_user_pass']));
if (!$login_result)
{
//登录失败
echo 'login error';
//关闭连接
ftp_close($conn_id);
die();
}
else
{
//登录成功
//echo 'success';
}
//ftp_close($conn_id);die();
@ftp_pasv($conn_id,1); // 打开被动模拟
//上传
if( is_dir($file) ) {
$contents_on_server = ftp_nlist($conn_id, $remote_file);
if(!in_array($remote_file."/.", $contents_on_server)) {
if(!ftp_mkdir($conn_id, $remote_file)) {
echo "There was a problem while creating $file/n";
exit;
}
}
}
else
{
$re = @ftp_put($conn_id,$remote_file,$file,FTP_BINARY);
if (!$re)
{
echo "put fail";
}
}
//关闭连接
ftp_close($conn_id);
}