TJMAudio Posted August 9, 2006 Share Posted August 9, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/16973-database-size/ Share on other sites More sharing options...
bradcis Posted August 9, 2006 Share Posted August 9, 2006 Are the images themselves stored in the database table? Quote Link to comment https://forums.phpfreaks.com/topic/16973-database-size/#findComment-71524 Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/16973-database-size/#findComment-71526 Share on other sites More sharing options...
redarrow Posted August 9, 2006 Share Posted August 9, 2006 $query=" SELECT sum(pic) as picture from xxxx": Quote Link to comment https://forums.phpfreaks.com/topic/16973-database-size/#findComment-71527 Share on other sites More sharing options...
bradcis Posted August 9, 2006 Share Posted August 9, 2006 If you storing the images in a directory, on image upload, you could get the file size and put that into the MySQL entry Quote Link to comment https://forums.phpfreaks.com/topic/16973-database-size/#findComment-71529 Share on other sites More sharing options...
redarrow Posted August 9, 2006 Share Posted August 9, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/16973-database-size/#findComment-71539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.