php - ftp_get - Warning: ftp_get(): Opening BINARY mode data connection

后端 未结 5 483
自闭症患者
自闭症患者 2021-01-13 07:04

I\'m trying to write a script that will download files from an FTP server. They\'re all fairly large (nearly 2GB each). The script starts running, but then eventually term

相关标签:
5条回答
  • 2021-01-13 07:38

    Try using ftp_close and ftp_connect as to reset your FTP connection.

    I had spent a good day on this one, trying everything I could find (ftp_pasv, ftp_alloc, changing to FTP_ASCII/FTP_BINARY), with no success.

    Some servers have limits on how much you can upload per session.

    0 讨论(0)
  • 2021-01-13 07:39

    I was having a similar problem and using the following solved it for me.

    ftp_pasv($conn_id, TRUE);  
    
    0 讨论(0)
  • 2021-01-13 07:41

    For anyone who might come by this question because of having the same issue. For me it was rather simple, the target location for the download didn't have enough free space for the file.

    0 讨论(0)
  • 2021-01-13 07:56

    Try to increase FTP_TIMEOUT (the default value is 90)

    ftp_set_option($conn_id, FTP_TIMEOUT_SEC, 180);
    

    It worked perfectly for me.

    http://www.php.net/manual/en/function.ftp-set-option.php

    0 讨论(0)
  • 2021-01-13 08:05

    Are you sure each file is binary?

    You may try to guess the file type from its extension in order to adjust the download mode, as suggested in this comment: http://www.php.net/manual/fr/function.ftp-get.php#86516

    0 讨论(0)
提交回复
热议问题