Obtain the php function of the remote file size. Copy the code as follows :? PhpfunctiongetFileSize ($ url) {$ urlparse_url ($ url); if ($ fp @ fsockopen ($ url [host], empty ($ url [port])? 80: $ url [port], $ error) {fputs ($ fp, GET.
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.1 \ r \ n ");
Fputs ($ fp, "Host: $ url [host] \ r \ n ");
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 running, the size should be 4445 bytes.
The http://www.bkjia.com/PHPjc/321208.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321208.htmlTechArticle code is as follows :? Php function getFileSize ($ url) {$ url = parse_url ($ url); if ($ fp = @ fsockopen ($ url ['host'], empty ($ url ['port'])? 80: $ url ['port'], $ error) {fputs ($ fp, "GET "....