【发布时间】:2020-06-11 15:40:24
【问题描述】:
我在尝试使用 file_get_contents 时遇到错误
$filepath = "sharedFolder/image.gif";
$contents = file_get_contents($filepath);
当试图在通过 Samba 共享的文件系统中抓取文件时。由于 VPN 连接出现问题,file_get_contents 找不到共享文件,并在尝试查找文件时挂断了整个脚本。有没有办法给 file_get_contents 添加一个大致相当于
的超时$ctx = stream_context_create(array('http'=>
array(
'timeout' => 15, //15 Seconds
)
));
$filepath = "sharedFolder/image.gif";
$contents = file_get_contents($filepath, false, $ctx);
但是对于通过 Samba 而不是 http 共享的文件系统上的文件?
【问题讨论】:
标签: php file-get-contents samba