1、服务器php环境缺模块get_headers及file_get_content函数用不了,临时使用curl替代
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//获取远程图片大小 $ch = curl_init($img_path['img']); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $rs = curl_exec($ch); $regex = '/Content-Length: ([0-9]*)/'; preg_match($regex, $rs, $matches); if(empty($matches[1]) || $matches[1]==0){ return false; } $remote_size = $matches[1]; |