i use meioupload behavior to upload files but i cant know how to sive
filesize with nice format like (2 mb , 10 kb) ..i see this function in
meioupload but i dont know how to use it


/**
     * Convert a size value to bytes. For example: 2 MB to 2097152.
     *
     * @author Vinicius Mendes
     * @return int
     * @param $size String
     */
    function sizeToBytes($size){
        if(is_numeric($size)) return $size;
        if(!preg_match('/^[1-9][0-9]* (kb|mb|gb|tb)$/i', $size)){
            trigger_error('MeioUploadBehavior Error: The max_size
option format is invalid.', E_USER_ERROR);
            return 0;
        }
        list($size, $unit) = explode(' ',$size);
        if(strtolower($unit) == 'kb') return $size*1024;
        if(strtolower($unit) == 'mb') return $size*1048576;
        if(strtolower($unit) == 'gb') return $size*1073741824;
        if(strtolower($unit) == 'tb') return $size*1099511627776;
        trigger_error('MeioUploadBehavior Error: The max_size unit is
invalid.', E_USER_ERROR);
        return 0;
    }

to upload new file downloads/add.ctp



<div class="files form">
<?php echo $form->create('Download',array('type' => 'file')); ?>
    <fieldset>
        <legend><?php __('Add FIle'); ?></legend>
    <?php

echo $this->Form->input('title');
echo $form->input('file_name', array('type' => 'file'));
$options =
array('d'=>'Document','P'=>'Pdf','A'=>'Audio','C'=>'Compressed','o'=>'Other');
echo $form->select('type',$options,'f',array('empty'=>false));

    ?>
    </fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>
<div class="actions">
    <h3><?php __('Actions'); ?></h3>
    <ul>

        <li><?php echo $this->Html->link(__('List Files', true),
array('action' => 'index'));?></li>
        <li><?php echo $this->Html->link(__('Add File', true),
array('action' => 'add')); ?> </li>
    </ul>
</div>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to