E
E
EvgMul2018-10-10 21:33:22
Yii
EvgMul, 2018-10-10 21:33:22

Why is the directory not created on the server?

Hello. I have the following problem.
Locally, this function works without problems:

public function upload($file)
    {
        if (strpos($file->type, "image") !== false)
        {
            $this->type = self::TYPE_IMAGE;

            $out_dir = '/uploads/images/'.substr(md5(time()), 0, 2).'/'.substr(md5(time()+1), 0, 2).'/';
        }
        else
        {
            $this->type = self::TYPE_OTHER;

            $out_dir = '/uploads/files/'.substr(md5(time()), 0, 2).'/'.substr(md5(time()+1), 0, 2).'/';
        }

        $out_file_name = md5(time()+2) . '.' . $file->extension;
        $out_file = $out_dir . $out_file_name;

        BaseFileHelper::createDirectory(Yii::getAlias("@webroot") . $out_dir);

        if ($file->saveAs(Yii::getAlias("@webroot") . $out_file))
        {
            $this->dir = $out_dir;
            $this->file_name = $out_file_name;
            $this->original_file_name = $file->baseName . '.' . $file->extension;

            return true;
        }
        else
            return false;
    }

On the server, this function cannot even create a directory.
Line
BaseFileHelper::createDirectory(Yii::getAlias("@webroot") . $out_dir);

Returns false. Checked the paths, everything is correct. I can't figure out what the problem is.
Tell me please. Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2018-10-10
@EvgMul

Have you set write permissions?

solution in comments

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question