ftp_get timeout with large files


I don’t have any problem to download files throught ftp with ftp_get except when I have a 4GB file.
It takes some times to get the file and I get this error :

ErrorException: ftp_get(): Timeout

I’m using this simple example here : https://php.net/ftp_get

$conn_id = ftp_connect($ftp_server);

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
    echo "Le fichier $local_file a été écrit avec succès\n";
} else {
    echo "Il y a un problème\n";

Is there any way to increase the timeout ? Or maybe another solution ?

Thanks !


Had the same problem before. I was trying to get too many files at one time.

The solution was to limit the amount of files to download and then if you have access to the FTP, try to improve the timeout or check the log to get more details. Check also if you can split this file in smaller ones.

Answered By – Phil Drolly

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published