Answer the question
In order to leave comments, you need to log in
Why file upload validation fails in yii?
Why is the file not validated in YII?
VIEW
<?php echo CHtml::form('','post',array('enctype'=>'multipart/form-data')); ?>
<?php echo CHtml::activeFileField($model, 'media'); ?>
<?php echo Chtml::error($model,'media'); ?>
<?php echo CHtml::submitButton('Next'); ?>
<?php echo CHtml::endForm(); ?>
CONTROLLER
$model=new Loadmix();
$dir=Yii::getPathOfAlias('webroot.mixmarker');
if(isset($_POST['loadmix']))
{
$model->attributes=$_POST['Loadmix'];
$model->media=CUploadedFile::getInstance($model,'media');
if($model->validate()){
...
...
MODEL
public $file;
public function role(){
return array(
array('file','file','types'=>'mp3'),
);
}
Tell me pliz what could be the problem?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question