Jump to content

Archived

This topic is now archived and is closed to further replies.

TJMAudio

Database Size?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
If you storing the images in a directory, on image upload, you could get the file size and put that into the MySQL entry

Share this post


Link to post
Share on other sites
i dont no if this will work but shold get the size of all files in a directory hope.

[code]
<?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";
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.