Question

i use meioupload to upload files..but i want to save size for everyfile i uploaded..so how to use meioupload to get uploaded file size..and if it not support this option..are there anyway to do that..

models/download.php

<?php
class Download extends AppModel {
    var $name = 'Download';

var $actsAs = array(
'MeioUpload' => array(
'file_name' => array(
'dir' => 'files',
'create_directory' => false,
'allowedMime' => array('application/pdf', 'application/
msword', 'application/vnd.ms-powerpoint', 'application/vnd.ms-excel',
'application/rtf', 'application/zip'),
'allowedExt' => array('.pdf', '.doc', '.ppt', '.xls',
'.rtf', '.zip'),
'default' => false,
)
)
);

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>
Was it helpful?

Solution

I believe that with the MeioUpload behavior - if you have a field in your database table where you are saving the file information called 'filesize' it will automatically save the file size in that field.

Did you try doing that? Then you can use the NumberHelper->toReadableSize() to turn that number into an easier to read number (in KB, MB, GB, TB for example).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top