21,887
社区成员
发帖
与我相关
我的任务
分享
function urlExist($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if (!$data) {
return "Domain could not be found";
}
else {
preg_match_all("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches);
$code = end($matches[1]);
if ($code == 200) {
return "Page Found";
}
elseif ($code == 404) {
return "Page Not Found";
}
}
}
echo urlExist('http://www.baidu.com/img/baidu_jgylogxo3.gif');
<?php
$path = 'http://www.baidu.com/img/baidu_jgylogxo3.gif';
if(!file_exists($path)){
echo "该文件不存在!!!";
exit();
}
$file_name="xx.gif"; //这里重命名
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename='.$file_name);
ob_end_clean();
readfile($path);
?>
<?php
$path = 'http://www.baidu.com/img/baidu_jgylogo3.gif';
$file_name="xx.gif"; //这里重命名
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename='.$file_name);
ob_end_clean();
readfile($path);
?>
header('Content-Disposition: attachment; filename=xx.gif');
这个头可以激活对话框
一个文件介绍php做下载