M
M
Mark2020-02-15 03:40:27
Yii
Mark, 2020-02-15 03:40:27

How to solve ImageUploadBehavior file saving issue?

Problem with ImageUploadBehavior from yii-dream-team/yii2-upload-behavior .

The image file is not saved to a directory.

In this case, the file name is correctly read and written to the database. For example: 15783295728133.jpg
The file goes to $_FILES

$_FILES array
kiss_11kb.1581726908.png

I thought it was an alias problem, I tried: @app, @backend, @frontend,etc.
Folder permissions: 755
Yii2 version: 2.0.32

Setting:
public function behaviors()
    {
        return [
            [
                'class' => '\yiidreamteam\upload\ImageUploadBehavior',
                'attribute' => 'miniature',
                'filePath' => '@backend/web/storage/.',
                'fileUrl' => '/storage/.',
            ],
        ];
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mark, 2020-02-20
@MarkLb

Loading into the Behavior variable was done by the beforeValidate() event. Since I have all the data validated in the form and the entity gets ready for work - validation was disabled, as a result - the event did not work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question