doyhq66282 2010-07-20 14:16
浏览 261
已采纳

ftp_put上传一个空文件

I'm trying to upload a file via ftp_put to a windows server.

my code is as follows:

    $date           = date('ymd');
    $file_name      = $date.'.csv';
    $file_location  = 'D:/inetpub/wwwroot/website.com/html/assets/'.$file_name;

//set up basic connection
$conn_id = ftp_connect(FTP_HOST, FTP_PORT);

// login with username and password
$login_result = ftp_login($conn_id, FTP_USER, FTP_PASS);

// check connection
if ((!$conn_id) || (!$login_result)) { 
    echo "FTP connection has failed!"; 
    exit;
}  else { 
    echo "Connected to FTP Server";
}

$upload = ftp_put($conn_id, $file_name, $file_location, FTP_ASCII);

// check upload status
if (!$upload) { 
    echo "FTP upload has failed!"; 
} else { 
    echo "File Uploaded";
}

// close the FTP stream 
ftp_close($conn_id); 

If I upload the file manually using filezilla, it works perfectly. If I use the code above, it creates an empty file.

  • 写回答

5条回答 默认 最新

  • donglinxia1541 2010-07-21 10:25
    关注

    It turns out that UKFast was blocking the connection and transfer. (They also require it to be Active Mode only).

    Now they've unblocked it, it's working perfectly. (Before it seemed to just time out)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题