|
-
May 18th, 2007, 06:59 PM
#1
Thread Starter
Addicted Member
[RESOLVED] How to get size of file in website
Hello
How can I get size of a file which website?
Example:
http://www.website/file.zip
How can I get size of file.zip?
Thx
-
May 18th, 2007, 09:29 PM
#2
Re: How to get size of file in website
-
May 19th, 2007, 06:46 AM
#3
Thread Starter
Addicted Member
Re: How to get size of file in website
filesize() doesn't work for files on websites.
-
May 19th, 2007, 07:04 AM
#4
Re: How to get size of file in website
Sorry, didn't read carefully enough.
You can't get the size of files on remote websites. Not easily and reliably, anyway
-
May 19th, 2007, 07:27 AM
#5
Re: How to get size of file in website
If the response sends a Content-Length header then you can get the size. This is not necessarily the size of the file though, it is the size f the response body.
If there is no Content-Length header, you'll need to download the entire file first.
-
May 19th, 2007, 07:33 AM
#6
Thread Starter
Addicted Member
Re: How to get size of file in website
 Originally Posted by visualAd
If the response sends a Content-Length header then you can get the size. This is not necessarily the size of the file though, it is the size f the response body.
If there is no Content-Length header, you'll need to download the entire file first.
How can I do it by using Content-Length?
-
May 19th, 2007, 07:36 AM
#7
Re: How to get size of file in website
i am going to work now. I will reply when I get back. If pena doesn't beat me to it.
-
May 22nd, 2007, 12:00 PM
#8
Thread Starter
Addicted Member
Re: How to get size of file in website
 Originally Posted by visualAd
i am going to work now. I will reply when I get back. If pena doesn't beat me to it.
Could you do it?
Thanks
-
May 22nd, 2007, 01:43 PM
#9
Re: How to get size of file in website
You can use the stream_get_meta_data() function to get the heads from an fopen wrapper.
PHP Code:
if (!($fp = @fopen($url, 'r'))) {
/* error here - as url could not be opened */
}
$metaData = stream_get_meta_data($fp);
$size = null;
foreach ($metaData['wrapper_data'] as $header) {
if (strpos(strtolower($header), 'content-length') !== false) {
$size = substr($header, strpos($header, ':') + 1);
break;
}
}
if (is_null($size)) {
/* Content-Length header not found */
}
-
May 23rd, 2007, 10:33 AM
#10
Thread Starter
Addicted Member
Re: How to get size of file in website
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|