php - file_get_contents 和 file_put_contents 的 FTP 超时

标签 php file ftp timeout file-get-contents

我正在尝试使用 ftp 服务器附加文件

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

这工作正常,但需要很长时间才能在失败时生成超时。我想设置在 FTP 上附加文件的超时时间。我查看了stream_context_create(),它确实支持FTP协议(protocol),但找不到连接超时的选项,就像HTTP协议(protocol)一样。设置 file_put_contents 或 file_get_contents 超时的其他方法可能是什么

最佳答案

也许这会有帮助?

ini_set("default_socket_timeout", $seconds);

关于php - file_get_contents 和 file_put_contents 的 FTP 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15154975/

相关文章:

powershell - FTP上传文件时出错

php - 从 Azure Web App 上运行的 PHP 访问 Blob 存储

php - 尝试创建 PHP 搜索脚本时搜索结果为空

python - 更改第一列中的数字

java - FTPClient.listFiles 没有以秒为单位返回时间

php - 使用 PHP glob 在 FTP 服务器上列出文件不起作用

php - 如果键相同,如何组合两个数组并将其分块

php - 如何在应用程序上为每个用户创建新的数据库或数据库实例?

java - 在java中读取格式化的文本文件

c - 我无法更改 c、Visual Studio 中的当前路径