使用PHP取远程文件的大小的3种方法
1、【最傻最天真的方法】
将文件使用file_get_contents取回后,strlen
或者存为文件后使用filesize 嘿嘿
2、【使用get_headers】
如果没有打开allow_url_fopen
会显示waring
Warning: get_headers() [function.get-headers]: URL file-access is disabled in the server configuration
示例代码如下:
3、【使用fsockopen,然后正则匹配出文件大小】
使用fsockopen向目标地址发送http request,然后根据服务器的response使用正则匹配