php ftp_get和奇怪的问题,在线等

xiefangzhen 2010-07-02 06:37:20
在对方unix服务器上下载数据,文件大小都能读出来,就是内容下载不了,什么原因呀,错误提示如下
501
Warning: ftp_get() [function.ftp-get]: Opening ASCII mode data connection for 50001_Award_8_514772.txt (501 Bytes).
...全文
127 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
xiefangzhen 2010-07-02
帮忙看看,收不到内容
set_time_limit(600);
$ftp_server="218.249.166.200";
$conn_id = ftp_connect($ftp_server,"8221") or die("Couldn't connect to $ftp_server");
ftp_login($conn_id,"sctest","222333");
ftp_pasv($conn_id, true);
echo ftp_get($conn_id,"abc.txt","/201007/02/50001_Award_8_514772.txt",FTP_ASCII);
回复
CunningBoy 2010-07-02
可能是因为防火墙,在ftp_get()之前加上ftp_pasv($resource, true);

原文摘自php网站文档的注释:http://php.net/manual/en/function.ftp-put.php
========================================================================
If when using ftp_put you get the one of the following errors:

Warning: ftp_put() [function.ftp-put]: Opening ASCII mode data connection

Warning: ftp_put() [function.ftp-put]: Opening BINARY mode data connection

and it creates the file in the correct location but is a 0kb file and all FTP commands thereafter fail. It is likely that the client is behind a firewall. To rectify this use:

<?php
ftp_pasv($resource, true);
?>

Before executing any put commands. Took me so long to figure this out I actually cheered when I did :D
回复
PIGer920 2010-07-02
501的意思是:Syntax error in parameters or arguments.

贴下你的代码
回复
发动态
发帖子
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
社区公告
暂无公告