Answer the question
In order to leave comments, you need to log in
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;
}
BaseFileHelper::createDirectory(Yii::getAlias("@webroot") . $out_dir);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question