Remote file size without downloading file

前端 未结 14 1822
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 03:01

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

14条回答
  •  醉梦人生
    2020-11-22 03:27

    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.

提交回复
热议问题