如何检查文件是否存在从url [英] How check if file exists from the url
本文介绍了如何检查文件是否存在从url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要检查远程服务器上是否存在特定文件。使用 is_file()
和 file_exists()
不起作用。
I need to check if a particular file exists on a remote server. Using is_file()
and file_exists()
doesn't work. Any ideas how to do this quickly and easily?
推荐答案
您必须使用CURL
function is_url_exist($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 200){
$status = true;
}else{
$status = false;
}
curl_close($ch);
return $status;
}
这篇关于如何检查文件是否存在从url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文