Loading Yii in a local file path

I need to upload images to the image path on my local site. how can i write a path?

error: $ Models-> image-> SAVEAS ('/ application / images');

image path C: \ XAMPP \ HTDOCS \ worldi \ application \ images

+4
source share
2 answers
$images_path = realpath(Yii::app()->basePath . '/../images'); $model->image->saveAs($images_path . '/' . $model->image); 
+17
source

Yii will use YiiBase :: getPathOfAlias ​​() to do this, which translates the alias to its corresponding path.
Yii predefines these aliases

 system: refers to the Yii framework directory; zii: refers to the Zii library directory; application: refers to the application base directory; webroot: refers to the directory containing the entry script file. ext: refers to the directory containing all third-party extensions. 

So using

$ imagePath = YiiBase :: getPathOfAlias ​​("webroot"). '/ images';

will provide you with the required results.

+4
source

Source: https://habr.com/ru/post/1391100/


All Articles