Get remote file size using URL in PHP

Here’s the best way to get the size of a remote file. Note that HEAD requests don’t get the actual body of the request, they just retrieve the headers. So making a HEAD request to a resource that is 100MB will take the same amount of time as a HEAD request to a resource that is 1KB. Since the file is remote, you’re completely dependent on the value of the Content-Length header.

I am trying to get image size of file size using php. Add this function on your function file.


I have use this way for display or show my zip file size. It works nicely on my site. Use bellows code, where you want to display this file size.


Leave a Comment

Your email address will not be published.