Yii2 Uploaded file question

Hello everyone.

Is there a way to create a folder and upload file in it.

I mean lets say i wanna upload a PDF file, my upload path is /uploads/.

Before the file gets uploaded i wanna create a folder like 9 dicember 2015 and upload the file inside it.

so the upload path would be /uploads/9 dicember 2015/uploadedfile

Can someone help?

http://www.yiiframework.com/doc-2.0/yii-helpers-basefilehelper.html#createDirectory()-detail

http://www.yiiframework.com/doc-2.0/guide-input-file-upload.html

Read the guide for uploaded file

http://www.yiiframew…ile-upload.html

Here is the method that save the uploaded file

http://www.yiiframew…As%28%29-detail

It use php move_uploaded_file() which DOES NOT create the directory tree

To create the directory tree you should use

\yii\helpers\FileHelper::createDirectory ( $path, $mode = 509, $recursive = true );

with recursive set to true (is the default) it will create the full path

http://www.yiiframew…filehelper.html

http://www.yiiframew…ry%28%29-detail

By the way I suggest you to use all number for the date without space or by using _ or - as separator.

Using ISO 8601 would be the best for readability YYYY-MM-DD