![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jun 2004
Location: Europe
Posts: 3,055
|
Php question for gurus: Displaying file size in MB not in bytes
How do you do it?
echo filesize("0001.wmv"); is doing to show bytes. How do you format it to show in MB's ? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
♥ ♦ ♣ ♠
Industry Role:
Join Date: Sep 2002
Posts: 10,592
|
mb=bytes\1024\1024
__________________
![]() ![]() ![]() "I'm selflessly supporting the common good, but only coincidentally looking out for No.1." |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
So Fucking Banned
Industry Role:
Join Date: Apr 2001
Location: N.Y. -Long Island --
Posts: 122,992
|
Code:
function formatbytes($file, $type) { switch($type){ case "KB": $filesize = filesize($file) * .0009765625; // bytes to KB break; case "MB": $filesize = (filesize($file) * .0009765625) * .0009765625; // bytes to MB break; case "GB": $filesize = ((filesize($file) * .0009765625) * .0009765625) * .0009765625; // bytes to GB break; } if($filesize <= 0){ return $filesize = 'unknown file size';} else{return round($filesize, 2).' '.$type;} } Code:
// USAGE echo formatbytes("$_SERVER[DOCUMENT_ROOT]/images/large_picture.jpg", "MB"); // would display the file size in MB |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Industry Role:
Join Date: Jun 2004
Location: Europe
Posts: 3,055
|
Quote:
you're the man Juicy. Now do the eyebrow for me again like you did in Atlanta at the bar. I need to show you that pix ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
So Fucking Banned
Industry Role:
Join Date: Apr 2001
Location: N.Y. -Long Island --
Posts: 122,992
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
MOBILE PORN: IMOBILEPORN
Join Date: Jan 2004
Location: Tinseltown NL
Posts: 16,502
|
Quote:
Good job, I was about to post something similar for him. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
So Fucking Banned
Join Date: Jan 2009
Posts: 2,377
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
So Fucking Banned
Industry Role:
Join Date: Apr 2001
Location: N.Y. -Long Island --
Posts: 122,992
|
the code is from google btw
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
MOBILE PORN: IMOBILEPORN
Join Date: Jan 2004
Location: Tinseltown NL
Posts: 16,502
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Confirmed User
Join Date: Nov 2002
Location: Blah
Posts: 217
|
Quote:
return(number_format($filesize, 2, '.', ',').' '.$type) This would show something like 1,321.26 KB etc. - Az |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Join Date: Aug 2008
Posts: 3,223
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 | |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
Quote:
![]() But props for finding it and posting it, Juicy. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
So Fucking Banned
Industry Role:
Join Date: Apr 2001
Location: N.Y. -Long Island --
Posts: 122,992
|
only have basic code exp from years ago just basics n shit lolll yeah i had to look at the code before i realized it was missing something loll
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 | |
MOBILE PORN: IMOBILEPORN
Join Date: Jan 2004
Location: Tinseltown NL
Posts: 16,502
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
Confirmed User
Industry Role:
Join Date: Mar 2004
Location: Rock Hill, SC
Posts: 5,370
|
Juicy has giant code balls
|
![]() |
![]() ![]() ![]() ![]() ![]() |