Re: how to extract filesize from meioupload with understable format ?
thanls 100rk it is work now On Jan 16, 12:45 am, 100rk wrote: > http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#Num... -- 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
Re: how to extract filesize from meioupload with understable format ?
thanks 100rk but i use cakephp1.3 is this anyway to use with 1.3? -- 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
Re: how to extract filesize from meioupload with understable format ?
http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::toReadableSize -- 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
Re: how to extract filesize from meioupload with understable format ?
how to format it to an human readable format On Jan 15, 9:13 pm, Thiago Belem wrote: > You should save the size in bytes and format it to an human readable format > (2 mb) on the view, with a helper. > > -- > Thiago Belem, > Desenvolvedor WEB > > Enviado do meu Android > Em 15/01/2012 14:59, "ahmed fakher" escreveu: > > > > > > > > > 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 > > > > > create('Download',array('type' => 'file')); ?> > > > > > > > > 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)); > > > ?> > > > > Form->end(__('Submit', true));?> > > > > > > > > > > > Html->link(__('List Files', true), > > array('action' => 'index'));?> > > Html->link(__('Add File', true), > > array('action' => 'add')); ?> > > > > > > > -- > > Our newest site for the community: CakePHP Video Tutorials > >http://tv.cakephp.org > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd 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 > > athttp://groups.google.com/group/cake-php -- 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
Re: how to extract filesize from meioupload with understable format ?
You should save the size in bytes and format it to an human readable format (2 mb) on the view, with a helper. -- Thiago Belem, Desenvolvedor WEB Enviado do meu Android Em 15/01/2012 14:59, "ahmed fakher" escreveu: > 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 > > > > > create('Download',array('type' => 'file')); ?> > > > > 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)); > >?> > > Form->end(__('Submit', true));?> > > > > > >Html->link(__('List Files', true), > array('action' => 'index'));?> >Html->link(__('Add File', true), > array('action' => 'add')); ?> > > > > -- > 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 > -- 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
how to extract filesize from meioupload with understable format ?
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 create('Download',array('type' => 'file')); ?> 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)); ?> Form->end(__('Submit', true));?> Html->link(__('List Files', true), array('action' => 'index'));?> Html->link(__('Add File', true), array('action' => 'add')); ?> -- 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