Home > Backend Development > PHP Tutorial > Get the remote file size with php, _PHP tutorial

Get the remote file size with php, _PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-12 09:07:04
Original
888 people have browsed it

php gets the size of the remote file,

The example in this article describes the method of getting the size of the remote file in php, and I share it with you for your reference. The specific implementation method is as follows:

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

I hope this article will be helpful to everyone’s PHP programming. You can like Pee’s article and we can make progress together.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1063235.htmlTechArticlephp obtains the remote file size. This article describes the method of obtaining the remote file size in php and shares it with you for your reference. . The specific implementation method is as follows: /* **Function: Get remote files...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template