Get Total Size of Selected Files - Page 2
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23

Thread: Get Total Size of Selected Files

  1. #16
    Junior Member
    Join Date
    Apr 2012
    Posts
    9
    Here is the output.

    Code:
    820965401344344223554709305548660210967818141462331484123014936079150809241531328316092265167335981755432723461255240452382504149825349399261673022691242427482594283012352922076129701970303579393059641131042021318088323216524633075057
    Here it is with line breaks.

    Code:
    820965
    4013443
    4422355
    4709305
    5486602
    10967818
    14146233
    14841230
    14936079
    15080924
    15313283
    16092265
    16733598
    17554327
    23461255
    24045238
    25041498
    25349399
    26167302
    26912424
    27482594
    28301235
    29220761
    29701970
    30357939
    30596411
    31042021
    31808832
    32165246
    33075057
    Last edited by bradgrafelman; 04-23-2012 at 09:45 AM. Reason: bbcode tags added

  2. #17
    Senior Member
    Join Date
    Aug 2002
    Location
    Norway
    Posts
    160
    OK. Your "adding" is like you add strings like
    PHP Code:
    $string1 '820965';
    $string2 '4013443';
    echo 
    $string1.$string2;

    // Thats a big differens to adding integers.

    $value1 820965;
    $value2 4013443;
    echo 
    $value1 $value2
    have a nice OO day!

  3. #18
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,840
    If you put the sizes into an array
    PHP Code:
    $sizes[] = filesize($path_file); 
    instead of
    PHP Code:
    $size=filesize($path_file); 
    then (after) the loop,
    PHP Code:
    $total_size array_total($sizes); 
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  4. #19
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    1,763
    Actually you'd use array_sum since there is no array_total (at least not as part of PHP).
    Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
    I'd rather be a comma, then a full stop.
    User Authentication in PHP with MySQLi - Don't forget to mark threads resolved - MySQL(i) warning

  5. #20
    Senior Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    236
    $result = mysql_query("SELECT * FROM videos WHERE user_id = '1'")
    or die(mysql_error());

    while($row = mysql_fetch_array( $result )) {

    $file = ''.$row['id'].'.flv';

    $path_file = $path.'/'.$file;

    $size = filesize($path_file);

    }

    This is your code If the above code is not working for You you can take the size of all file in array like the below and just use the array_sum() to get the size of total file

    $result = mysql_query("SELECT * FROM videos WHERE user_id = '1'")
    or die(mysql_error());

    $total_size = array();
    while($row = mysql_fetch_array( $result )) {

    $file = ''.$row['id'].'.flv';

    $path_file = $path.'/'.$file;

    $total_size[] = $size = filesize($path_file);

    }
    $sum_of_filesize = array_sum($total_size);

    This will help You

  6. #21
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,840
    Quote Originally Posted by Derokorian View Post
    Actually you'd use array_sum since there is no array_total (at least not as part of PHP).
    Ah, yes; I was thinking of another language (perhaps I should have checked the manual first).
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  7. #22
    Junior Member
    Join Date
    Apr 2012
    Posts
    9
    That did it.

    Thanks!

  8. #23
    Senior Member
    Join Date
    Apr 2012
    Location
    India
    Posts
    236
    That did it.

    Thanks!


    That was only the matter of taking all the value in array and just add all asociative value of array

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •