Gunjan Nigam
Gunjan Nigam

Reputation: 1393

FTP Timeout for file_get_contents & file_put_contents

I am trying to append files on ftp server using

file_put_contents("ftp://".$ftp_user_name.":".$ftp_user_pass."@".$ftp_server."/".$destFile, $outputStr, FILE_APPEND)

This works fine, but it takes a lot of time to generate a timeout on failure. I want to set the time out for appending the file on FTP. I had a look at stream_context_create() which does support FTP protocol but could not found option for connection timeout, like it has for HTTP protocol. What could be the other way for setting time out for file_put_contents or file_get_contents

Upvotes: 2

Views: 1438

Answers (1)

drull
drull

Reputation: 509

Maybe this will help?

ini_set("default_socket_timeout", $seconds);

Upvotes: 2

Related Questions