PHP: get remote file size with strlen? (html)

前端 未结 3 1886
梦如初夏
梦如初夏 2021-01-15 03:58

I was looking at PHP docs for fsockopen and whatnot and they say you can\'t use filesize() on a remote file without doing some crazy things with ftell or something (not sure

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-15 04:06

    it will fetch the whole file and then calculate the filesize (rather the string length) out of the retrieved data. usually filesize can tell the filesize directly from the filesystem without reading the whole file first.

    so this will be rather slow, and will everytime fetch the whole file before being able to retrieve the filesize (string length

提交回复
热议问题