以下内容读取大小,但由于某种原因不下载文件。它输出正确的字节,因此文件确实存在但无法下载并写入本地。有什么提示吗?
<?php
$ftp = ftp_connect("server");
$login = ftp_login($ftp, "user", "pw");
if ((!$ftp) || (!$login)) {
echo "cant connect <br>";
exit;
} else {
echo "connect ok <br>";
}
$local = fopen("xml.xml","w");
ftp_pasv($ftp, true);
$transfer = ftp_fget($ftp, $local,"dir/text.xml", FTP_BINARY, 0);
$size = ftp_size($ftp, "dir/text.xml");
echo "size is $size<br>";
if (!$transfer) {
echo "cant download<br>";
} else {
echo "download ok <br>";
}
ftp_close($ftp);
?>