php获取远程图片体积大小的实例_php实例_脚本之家
澳门十大电子游戏平台,直接看代码吧,很好明白的复制代码
代码如下://用法 echo remote_filesize;$url =
”
remote_filesize;
function remote_filesize{// start output buffering ob_start();//
initialize curl with given uri $ch = curl_init; // make sure we get the
header curl_setopt($ch, CURLOPT_HEADER, 1); // make it a http HEAD
request curl_setopt($ch, CURLOPT_NOBODY, 1); // if auth is needed, do
it here if && !empty { $headers = array(‘Authorization: Basic ‘ .
base64_encode; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); }
$okay = curl_exec; // get the output buffer $head =
ob_get_contents(); // clean the output buffer and return to previous
// buffer settings ob_end_clean(); // gets you the numeric value from
the Content-Length // field in the http header $regex =
‘/Content-Length:ss/’; $count = preg_match($regex, $head,
$matches); // if there was a Content-Length field, its value // will now
be in $matches[1] if { $size = $matches[1]; } else { $size =
‘unknown’; } $last_mb = round;$last_kb = round; return $last_kb . ‘KB
/ ‘ . $last_mb.’
MB’;}函数的思路是,先CURL获取图片到缓冲区,然后正则获取图片的Content-Length信息就OK了。
相关文章
- 澳门十大电子游戏平台影着协强制大刀月底斩向网吧,间接承认盗版合法
- 澳门十大电子游戏平台JS文件中的汉语在网页上海展览中心示为乱码化解方式,href不做事的难点_javascript本领_脚本之家
- 澳门十大电子游戏平台用JavaScript呈现随机图像或援用_图象特效_脚本之家
- 特斯拉两大持股人二季度均减少持有股票数量超20
- 【澳门十大电子游戏平台】squid代理服务器,Squid代理服务器安装
- 澳门十大电子游戏平台Ganglia监控Hadoop相关配置及监控指标说明
- js_脚本之家
- php获取远程图片体积大小的实例_php实例_脚本之家
- arcgis for js 修改infowindow样式的方法_javascript技巧_脚本之家
- JS之if语句对接事件动作逻辑_基础知识_脚本之家