A
A
AlexSer2019-10-10 11:27:51
Yii
AlexSer, 2019-10-10 11:27:51

How to setup Krajee input file for yii2?

I installed a widget for downloading files from Krajee
Krajee input
When I upload a file once, everything goes well, but I upload the same file and the progress bar is shown in red only for a second, and then it goes further green and the inscription "done" appears, because of this user confusion. I want it to turn red when an error occurs and stop at a percentage, and display an error, for example, "this file has already been uploaded before."
Code from Yii2 download action:

public function actionUpload($file)
    {
        if(ImportFile::find($file)){
            return [
                'error' => 'Файл уже существует'
            ];
        }else{
            $model = new UploadFiles();
                $model->dataFiles = UploadedFile::getInstances($model, 'dataFiles');
                if ($model->upload()) {
                    $model->readData();
                    return true;

                }else{
                    return [
                        'error' => 'Ошиюка загрузки файла'
                    ];
                }
         
        }
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question