Yii Framework Forum: Behavior to save Files - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Behavior to save Files Rate Topic: -----

#1 User is offline   Ismael 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 02-June 09
  • Location:Brazil

Posted 29 September 2009 - 08:14 AM

This behavior automate the tedius procedure to save the file in to the disk.

public function behaviors()
{
        return array('saveFileBehavior' => array('class' => 'SaveFileBehavior',
                                                 'campo' => 'myTableField', // field in table which stores the file name
                                                                           )
                   );
}

<div class="simple">
	<?php echo CHtml::activeLabelEx($model, 'myTableField'); ?>
	<?php echo CHtml::activeFileField($model, 'myTableField', array('size' => 40)); ?>
</div>





What does this Behavior?

It saves the file automactly here:

/protected/<someFolder>/<primary_key>/<table_attribute_name>

It's very simple and it works.
You may customize it, i don't know if it'll work for everyone.

Attachments are in the post, just download them here: http://www.yiiframew...oad/#entry20451
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users