File Size On External Files?

Started on the old forum in January 2009 · view the original in the archive · old links redirect here

5 replies · 560 views · started 17 years ago · 1 min read

3 participants
something else Fellow · 2,296 posts #1

iv been try to add file sizes to external links in the vault i have got it half working but its not bringing back size of all files is there something im doing wrong? or is it not possible with all files on all servers?

///$file = "http://somesite.con/files/music.mp3";////example file
$something = get_headers($file, 1);        
$size = $something['Content-Length'];
echo "<a href=\"$file\">music.mp3</a> $size bytes
";
something else Fellow · 2,296 posts #2

i guess i could have if(($size=="")||($size=="0")){ $size = "unkown"; }

but its not really the solution

alesh Lead · 604 posts #5

or u can add a function

function urlfilesize($url,$thereturn) {
if (substr($url,0,4)=='http') { 
$x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
$x = $x['content-length'];
            }
else { $x = @filesize($url); }
if (!$thereturn) { return $x; }
elseif($thereturn == 'mb') { return round($x / (1024*1024),2); }
elseif($thereturn == 'kb') { return round($x / (1024),2); }
}

eeeeerrr....

Guest #6

get_headers ????????

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close