I want to upload a file using Chtml in Yii. Table have 3 fields( id, name, attachment). In the index.php had following code.
Controller action
I want to add file attachment to this form. How save the file name in database field and file in folder using chtml?
<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?