标签:
<?php // 快速获取远程文件大小 // http 文件 $url = ‘http://bbs.csdn.net/topics/360076220‘; // ftp 文件 // $username = ‘xxxx‘;//ftp帐号 // $password = ‘xxxx‘;//ftp密码 // $url = ‘xxx.xxx.xxx/xx.xxx‘; //ftp服务器地址+文件路径+文件名例如: ftp.t35.com/down.zip // $ftp_server = "ftp://" . $username . ":" . $password . "@" . $url; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_URL, $ftp_server); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); $output = curl_exec($ch); curl_close($ch); preg_match(‘#Content-Length: (\d+)#i‘, $output, $arr); if (isset($arr[1])) { echo ‘远程文件大小: ‘, $arr[1], PHP_EOL; } else { echo ‘error‘, PHP_EOL; }
标签:
原文地址:http://my.oschina.net/meowmeow/blog/422127