S
S
Skrolea2016-06-02 17:46:06
Yii
Skrolea, 2016-06-02 17:46:06

Why is the file not saving?

I save the file in the model (before that, everything worked on another site)

public function upload() {

        if ($this->validate()) {
            foreach ($this->imageFiles as $file) {

                $md5file = substr(md5(microtime() . uniqid()), 0, 10);

                if ($file->saveAs('uploads/' . $md5file . '.' . $file->extension)) {
                    $dbsave = new Photos();
                    $dbsave->action = $this->action;
                    
                    $dbsave->url = 'uploads/' . $md5file . '.' . $file->extension;
                    
                    $dbsave->thumb = 'uploads/thumbs/' . $md5file . '.' . $file->extension;                 
                
                    Image::crop(Yii::getAlias($dbsave->url),580,710,[170,10]) ->save(Yii::getAlias($dbsave->thumb), ['quality' => 100]);
                   
                    $dbsave->save();
                }
            }
            return true;
        } else {
            return false;
        }
    }

I get an error
Save operation failed
↵
Caused by: ImagickException
unable to open image `uploads/thumbs/2cee633e90.jpg': No such file or directory @ error/blob.c/OpenBlob/2709

The paths are all correct - I check like this:
print_r($dbsave->thumb);
     print_r(Yii::getAlias($dbsave->thumb));

What can be wrong?
updated
Changed imagick version - it worked.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2016-06-02
@VladimirAndreev

rights?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question