2017-03-14 21:30
采纳率: 0%
浏览 148


I have been playing around with a few php scripts trying to first at least get the php file to connect to the ftp on my distributors file and THEN i would like it to save on my file. I was going to save this as a cron to run this script daily. I can't get it to connect to the distributors ftp. Their ftp access is The exact location of the file is I can acces it with filezilla and my browser. This is a different language to me. Any help would be great!

$conn_id = ftp_connect("");
$login_result = ftp_login($conn_id, "USERNAME", "PASSWORD");

if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
} else {
echo "Connected";

// get the file
$local = fopen("products.xml","w");
$result = ftp_fget($conn_id, $local,"httpdocs/products.xml", FTP_BINARY);

// check upload status
if (!$result) {
echo "FTP download has failed!";
} else {
echo "Downloaded";

// close the FTP stream

If I do not use the full url to the ftp file I do not get a login when using a browser.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • drrc61668568 2017-03-14 21:42

    You supplied a wrong parameter to ftp_connect(), this function accept as parameter the hostname, not url.

     $conn_id = ftp_connect("");
    解决 无用
    打赏 举报