Is it safe to keep user’s uploaded files in runtimes directory,
There was not enough information on Yii’s documentation. (http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/).
I wanted to make sure that Yii would not automatically remove or change files inside this directory and whether or not it is technically right to store user’s uploaded files under runtimes directory
Why you don’t create a seperate folder for user data. I thinks it’s usefull to seperate user-uploaded files and framework files, which may be modified and/or deleted without your interaction.
Just create an alias to a custom folder and you are fine. Also this gives you the option to move all user uploaded files to a different location(dev/prod env. or serverchange) by just changing the alias’ target. (No database change required, if you let yii manage all files).
// inside config.php
// inside your app use only this alias, even if you could use 'application.data' in this example, to keep the ability to move the files
$n = new SomeFanyClassRequieringALocation(Yii::getPathofAlias('userfiles.username').$imageid.'.jpg'));
Thanx for the answer Suralc,
I think that is a better solution. but just out of curiosity do you know when i can use this directory? i have seen that Gii and some other modules use it, but i really don’t know when i’m allowed to store my files on runtimes directory.
This directory is used internally by Yii and is not meant to be used by users.
You should create a separate folder for user uploaded files, outside the Yii’s protected folder.