Quick question; How can I get the file size of the web page?
13 4386
Heya, AJM.
Navigate to the directory and execute an `ls -l` or Get Info in the Finder :P
Alternatively, you might be interested in the filesize() function.
Sometimes when I want to try stuff like this in php. They have a simple function out of it! X|
Thanks!
Actually it is not working! I thought it would work on the first try, but no. Its not displaying anything! I want it to be able to read the file size of websites.
[PHP]$GetSite = $_GET['url'];
$f = fopen($filesize, 'r');
==HTML==
<tr>
<td>File Size:</td>
<td><? echo filesize($filesize) .' bytes'; ?><hr></td>
</tr>[/PHP]
Heya, AJM.
Is $filesize the full path to the file? Try using file_exists(), or file_get_contents() to make sure that the file you're looking for is really there.
Well I do have those working now, but they seem not to help me a lot.
Well I do have those working now, but they seem not to help me a lot.
Working how? That the file exists? If so, then filesize doesn't work remotely.
You may want to look into using cURL and it's settings for dealing with headers.
Here is how:
[PHP]if(file_exists($GetSite))
{
echo filesize($GetSite) .' bytes';
}else{
echo"<font color=\"#FF0000\">Error: Can't get file size!</font>";
}[/PHP]
I don't know where to look for what you suggested.
Heya, AJM.
What would be an example of the value of $GetSite?
Heya, AJM.
filesize() only works on local files. Are these files hosted on the same server as your filesize script? Try using the file path instead of the URL.
If these files are hosted on a different server, here's my recommendation: - Contact the individual who runs the other site and ask him to set up a filesize script or else provide you with the filesizes, or...
- Set up a cron script to download the files every night and cache their sizes. Then, instead of calculating the size of each file, you'd use the stored values (how often would the filesize change, anyway).
- If there's a LOT of files, you might want to store the last (e.g.,) 3 sizes that your script found, and for each file where all three values are the same, only download it, say, once per week instead.
Again, cURL will do what you're after. curl_getinfo() will prove useful.
Again, cURL will do what you're after. curl_getinfo() will prove useful.
I think from a design standpoint, what this script really needs is a way to cache filesizes. Suppose there are 10 files that you need to determine the sizes of, and each one averages 1 MB. That means that EVERY time the User loads a page, he has to wait for your server to download 10 MB.
AND, what happens when one User loads the page, and while he's waiting, a second User attempts to load the page? The second User will likely have to wait not only for the server to download all the files for him, but he'll have to also wait for the server to finish downloading the last User's files!
On the other hand, if the server were to automatically cache these filesizes by downloading the files once per week, then it can fetch these saved values instantaneously, plus it saves bandwidth... and how often are these files going to significantly change in size, anyway?
I agree with you, but not from a 'design standpoint,' but more in the way of saving bandwidth, both for the server and the client. It's always a good idea to save results and only update when necessary, but I also think it's a good idea to use cURL in order to accomplish this particular example, along with saving the results. cURL has a lot of options, and I believe you can specify exactly how much of the remote document you would like to retrieve. You can get only the request header, which should have the file size in it, and if not, I'm sure theres a way to do it without having to retrieve the entire file. Files usually give their file size within themselves.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason Steeves |
last post by:
Can someone please point me in the right direction for displaying word
documents onto a webpage? The word documents will contain
text/tables/pictures. I am new to this and can't quite find what I...
|
by: Johan Christensson |
last post by:
Hi.
Is there any other ways of displaying a webpage in an VB.Net form other then
using the "Microsoft Web Browser" object? Any third-party?
/Johan Ch
|
by: comp.lang.php |
last post by:
I have currently devised a way to display up to 3,000 records via
PHP/HTML by using pagination techniques that stuff an entire DB query
resultset into a $_SESSION object to use within pagination.
...
|
by: M.L. |
last post by:
When loaded from my hard drive, the webpage I'm working on renders fine
on IE6, Firefox 2.0.0.1, and Opera 9.02. However, after uploading it to
the web there are 2 images that fail to display on...
|
by: sureshreddy |
last post by:
hi friends,
I want the time to be displayed for a webpage to redirect to another webpage. You can see this concept in job sites when we fill all the details and click the search button it displays...
|
by: hestres |
last post by:
Hello,
I'm working on some link styles for this page:
http://www.house.gov/velazquez/lh0205tres/reports.html
I want all the links to always display in red (#CC0000), but in IE6
and 7 they...
|
by: Blue10 |
last post by:
Hi,
I would like to be able to display thumbnail versions of the full images on my website.
Currently I have to make the thumbnails manually so I wonder if there is any way of displaying reduced...
|
by: mikec87 |
last post by:
I am very new with PHP...started doing this a few days ago to help someone and I need some help please. I have a webpage that is not displaying the records I want it to. The sql is correct, and I...
|
by: Jeff |
last post by:
hi
asp.net 2.0
I have a image (.jpeg) stored in sql server 2005 and now I want to display
it on a webpage.
So I created a webpage (Image.aspx) which just writes the buffer data to the...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |