How to get attribute name from the widget in yii 1

283 views Asked by At

I used widget in my web application to upload files. In my view file, I used following widget code:

<?= $this->widget('application.components.FileUploadWidget',array(
                'model'=>$model,
                'attribute'=>'f_5',
                'htmlOptions'=>array('class'=>'form-control')
            ),true) ?>

I could not retrieve name of the uploaded file.How can I get the name of the uploaded file from the widget?(For example, if I upload file called image.jpg, I will be able to get image.jpg name itself )

1

There are 1 answers

1
Passionate Coder On

Try to print this

public function actionUpload()
{
    $model= new YourModel();
    if(isset($_POST['YourModel']))
    {
        $image = CUploadedFile::getInstancesByName('f_5');

    echo "<pre>";print_r($image);
    }