Jump to content


Photo

Database Size?


  • Please log in to reply
5 replies to this topic

#1 TJMAudio

TJMAudio
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 09 August 2006 - 12:39 AM

I am making an image hosting site, and I am wondering how I would display something like this...

<Total Images> (<Total Size>) images hosted!

How would I print out the total amount of images and the total size of images in my database?

Thanks.
:: My Site ::
Feel free to critique...

#2 bradcis

bradcis
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 09 August 2006 - 12:42 AM

Are the images themselves stored in the database table?

#3 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 09 August 2006 - 12:44 AM

if you are storing the images in the database then you could simply echo out the sum of the size of all the blob fields and the number of rows of the table containing all the images.

if they are in a folder you could read the contents of the folder and echo out the number of files in there and grab the size of each file - but that will be very slow if you're hosting thousands of images
follow me on twitter @PHPsycho

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 August 2006 - 12:45 AM

$query=" SELECT sum(pic) as picture from xxxx":

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 bradcis

bradcis
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 09 August 2006 - 12:46 AM

If you storing the images in a directory, on image upload, you could get the file size and put that into the MySQL entry

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 August 2006 - 01:00 AM

i dont no if this will work but shold get the size of all files in a directory hope.

<?php

$filename="xxxxxx";
$filemode="r";

if(!$a=fopen($filename,$filemode){

while(!feof($a){

$file=fgets($a);

}

$file=files[];

foreach($file as $num) {

$size=filesize($num);

echo "the size of all files are: $size";
}
 }else{
echo "no file exist";
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users