Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

File Upload

$
0
0
I want to upload a file using Chtml in Yii. Table have 3 fields( id, name, attachment). In the index.php had following code.
<form>
    <?php $name='abcd'; ?>
    <?php echo CHtml::textArea('Text', '',array('maxlength' => 300, 'rows' => 4, 'cols' => 30)); ?>
    <?php  echo CHtml::button('Send', array('submit' => array('site/contact','name'=>$name)));  ?>
</form>


Controller action
public function actionContact()
        {
            $model= new Message;
            $name=$_REQUEST['name'];
            if(isset['$_REQUEST['name'])
            {
               $model->name=$name;
               $model->save();
            }
         }


I want to add file attachment to this form. How save the file name in database field and file in folder using chtml?

Viewing all articles
Browse latest Browse all 18717

Trending Articles