php获取远程文件的大小

WBOY
Release: 2016-06-20 13:03:45
Original
1053 people have browsed it

php获取远程文件的大小,具体代码如下:

<p>/*</p>**功能:获取远程文件的大小,返回值的单位是:字节<br />*/<br />function get_fileSize($url){<br />	if(!isset($url)||trim($url)==''){<br />		return '';<br />	}<br />	ob_start();<br />	$ch=curl_init($url);<br />	curl_setopt($ch,CURLOPT_HEADER,1);<br />	curl_setopt($ch,CURLOPT_NOBODY,1);<br />	$okay=curl_exec($ch);<br />	curl_close($ch);<br />	$head=ob_get_contents();<br />	ob_end_clean();<br />	$regex='/Content-Length:\s([0-9].+?)\s/';<br />	$count=preg_match($regex,$head,$matches);<br />	return isset($matches[1])&&is_numeric($matches[1])?$matches[1]:'';<br />}
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template