steviez Posted November 23, 2007 Share Posted November 23, 2007 Hi, I am trying to make my code work, if my users have a quota limit of say 100MB and they try to upload a file bigger than what quota they have left i need it to not allow then to do so. My code so far for their quota: <?php // Select Total Space Used $sql = "SELECT SUM(size) AS sum_size FROM `uploads` WHERE uploader = '".$user_name."' "; $result = mysql_query($sql) or die(mysql_error()); $i = mysql_fetch_array($result); $space_used = $i['sum_size']; $max_space = $settings['max_free_space'] * 1024 *1024; //100MB // If Over Account Quota if($space_used > $max_space){ $over_use = true; }else{ $over_use = false; } $smarty->assign("over_use", $over_use); // Show Space Used As % $smarty->assign("used",number_format($space_used/$max_space*100,0)."%"); $smarty->assign("used_sub",ByteSize($space_used)." out of allowed ".ByteSize($max_space)); ?> Is this possable? Link to comment https://forums.phpfreaks.com/topic/78548-solved-help-with-quota/ Share on other sites More sharing options...
xyn Posted December 5, 2007 Share Posted December 5, 2007 1. collect all their files they have. 2. add the file sizes up. 3. subtract step 2 by the 100mb limit. 4. if statement, to check their new file is less than or equal to step 3 Link to comment https://forums.phpfreaks.com/topic/78548-solved-help-with-quota/#findComment-406947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.