Home > Backend Development > PHP Tutorial > Hikvision hard disk video recorder remote php function to obtain remote file size

Hikvision hard disk video recorder remote php function to obtain remote file size

WBOY
Release: 2016-07-29 08:41:37
Original
2004 people have browsed it

Copy code The code is as follows:


function getFileSize($url){
$url = parse_url($url);
if($fp = @fsockopen($url['host' ],empty($url['port'])?80:$url['port'],$error)){
fputs($fp,"GET ".(empty($url['path'])? '/':$url['path'])." HTTP/1.1rn");
fputs($fp,"Host:$url[host]rnrn");
while(!feof($fp)){
$tmp = fgets($fp);
if(trim($tmp) == ''){
break;
}else if(preg_match('/Content-Length:(.*)/si',$tmp ,$arr)){
return trim($arr[1]);
}
}
return null;
}else{
return null;
}
}
//Call method
echo getFileSize("http:/ /www.jb51.net/images/logo.gif")
?>


After everyone runs it, the size should be 4445 bytes.

The above introduces the PHP function for obtaining the remote file size of Hikvision hard disk video recorder remotely, including the remote aspects of Hikvision hard disk video recorder. I hope it will be helpful to friends who are interested in PHP tutorials.

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