Acess To The Parent Directory

Hey i have my images folder "resources" in the same path as controllers and models.

Right now i can save them and access them in my localhost.

But online i can only save them. Someone can help-me ?

To access them via localhost i use this : dirname(Yii::getAlias(’@web’)).’/resources’.’/’.$resource->filename.

Check that your resources folder is accessible from web (located inside webroot and is readable by webserver).

If you’re storing files inside non-accessible folder (for example, one level higher than webroot) then you have several options here:

  1. move your files inside subfolder of web-accessible directory (htdocs/uploads/)

  2. create symlink from webroot to your actual folder (check followsymlinks also)

  3. publish images using assets manager (can be good, can be bad idea)

  4. return images by script (bad idea)

By default, yii’s basic app structure is the following:

  • controllers

  • models

  • views

  • web

You can store all this inside webroot, but this is not good. It’s better to have structeru like

/somepath/project_name/controllers

/somepath/project_name/models

/somepath/project_name/views

/somepath/project_name/…

/somepath/project_name/htdocs <<-- here’s your webroot defined by server config.

So check webserver config for details.