Remote file size without downloading file

2018-12-31 05:37发布

Is there a way to get the size of a remote file http://my_url/my_file.txt without downloading the file?

标签: php curl
13条回答
何处买醉
2楼-- · 2018-12-31 06:09

Since this question is already tagged "php" and "curl", I'm assuming you know how to use Curl in PHP.

If you set curl_setopt(CURLOPT_NOBODY, TRUE) then you will make a HEAD request and can probably check the "Content-Length" header of the response, which will be only headers.

查看更多
登录 后发表回答