Need help, kinda lost
Posted: Wed Nov 17, 2010 1:15 pm
Ok so I have a page that looks in a directory and lists all files in that directory as links. Everything is working great except one thing, the filesize. I can get the file size in byte with $filesize = filesize($file) and then printing it with the rest of the code but here's what I have right now.
$filesize = filesize($file);
if($filesize < 1048576) {
$file_kb = round($filesize / 1024, 2);
}
else {
$file_kb = $filesize;
}
and then it prints on the page like this...
print "<a href=$temp>$file</a> | size: $file_kb KB | type: ".$ext." <img src=\"../images/icon-document.png\" width=\"13\" height=\"18\" alt=\"Document\" title=\"Document\" />
</li>";
but it always shows up as size: 0 kb I can't figure out why it wont give me the correct filesize. Like I said if I just do $filezise = filesize($file) then in the print do size: $filesize KB it shows in bytes, but I need it in kb. please help. thank you
$filesize = filesize($file);
if($filesize < 1048576) {
$file_kb = round($filesize / 1024, 2);
}
else {
$file_kb = $filesize;
}
and then it prints on the page like this...
print "<a href=$temp>$file</a> | size: $file_kb KB | type: ".$ext." <img src=\"../images/icon-document.png\" width=\"13\" height=\"18\" alt=\"Document\" title=\"Document\" />
</li>";
but it always shows up as size: 0 kb I can't figure out why it wont give me the correct filesize. Like I said if I just do $filezise = filesize($file) then in the print do size: $filesize KB it shows in bytes, but I need it in kb. please help. thank you