L
L
Lev K2016-05-22 16:26:16
Yii
Lev K, 2016-05-22 16:26:16

How to upload multiple files in yii?

Hello! See here how to upload files.
In the case of one file, I did this and everything worked:

if ($model->load(Yii::$app->request->post())) {
            $model->Scan_chek = UploadedFile::getInstance($model, 'Scan_chek');
                if ($model->save()) ...

I did not use the upload() method as written in the article, I looked into the database, saw the file, everything is fine!
Now I want to upload some files, made the necessary changes. Yii started swearing at sql query 551dd79531ba49dfa84699b8fc67fb51.png
I did it like this:
if ($model->load(Yii::$app->request->post())) {
            $model->Scan_chek = UploadedFile::getInstances($model, 'Scan_chek');
            if ($model->upload())
                if ($model->save())

Выдает ошибку : move_uploaded_file(uploads/11.jpg): failed to open stream: No such file or directory
public function upload()
    {
        if ($this->validate()) {
            foreach ($this->Scan_chek as $file) {
                $file->saveAs('uploads/' . $file->baseName . '.' . $file->extension); <- указывает сюда
            }
            return true;
        } else {
            return false;
        }
    }

Не подскажете где кроется истина и что это за uploads ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Александр N++, 2016-05-22
@sanchezzzhak

папки нету uploads в директории
web/uploads

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question