in reply to Finding the size of a directory

Are you trying to sum up the total? Rather than this:

$total = ($st->size)/1048576;#converts from bytes to MB

Do you want this?

$total += ($st->size)/1048576;#converts from bytes to MB

I would recommend collecting the total first and then dividing by 1M.

Also, you should declare $total in the scope of the size function so that it will start at zero each time you press the size button.

Update Added more comments

Still Unemployed!