Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3633070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:36:22+00:00 2026-05-19T00:36:22+00:00

Is there way to determine filesize of html file forexample i have a url

  • 0

Is there way to determine filesize of html file
forexample i have a url

http://url/item/id/1

can i determine the size of files when this url is loaded

I want to show in page 256 Kb loaded in 0.268 seconds at the end of page

try updates

on localhost/testing/index.php

echo filesize("http://localhost/testing/testing.html");

on localhost/testing/testing.html

<html>
    <head>
    </head> 
    <body>
        <img src="test.jpg"/>
    </body>
</htm>

on apache error.log

 [Fri Dec 31 14:46:05 2010] [error] [client ::1] PHP Warning:  filesize(): stat
 failed for http://localhost/testing/testing.html in /var/www/testing/index.php 
 on line 4

on index.php if i do

echo filesize("/var/www/testing/testing.html");

then i get 80 bytes that is without any image

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:36:23+00:00Added an answer on May 19, 2026 at 12:36 am

    You might want to hold your page render in a buffer (using ob_start()) and then parse it prior to flushing the buffer:

    1) You’ll want to save the buffer contents prior to rendering using ob_get_contents() (obviously this won’t work if you haven’t triggered the output buffer using ob_start()) (just to avoid having to call ob_get_contents() multiple times).

    2) Check the size of the buffer using strlen($varname), unless you’re using mbchar types (unicode) in your HTML, then you’ll have to look at alternate methods.

    3) Then, parse the buffer for any external CSS files or img tags (should be do’able with a single regex search).

    4) Iterate through the list of external CSS files and img tags and get their individual file sizes.

    5) Add the CSS and img file sizes to the buffer size and there you go. Total file size.

    (Note that anything else that incurs an HTTP request would also have to be calculated)

    Simply getting filesize for testing.html won’t give you all the data you’re looking for (unfortunately), as it only calculates the size of the given file; not any of its contents.

    I’d be willing to bet that there’s already something out there floating on the OS wagon somewhere that would do most (if not all) of this for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an cross-platform way to determine the maximum file size of the host
There are actually three ways I have in mind to determine a files size:
Is there any way to determine if a text file is currently open in
Is there a way to determine the unshared memory size of a process on
Is there a way to determine the optimal cache size (L1 and L2 possibly)
Is there a way to determine if a file is a binary or text
Is there any way to determine or force a CSS file to be re-cached
Is there a way to determine if an item, in my case the webbrowser,
Is there a way to determine whether or not a font can render a
Is there a way to determine if the process may execute a file without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.