我需要将图像上传到我本地网站的图片路径..我怎么能写路径?
错误:$ model-> image-> saveAs('/ app / images');
图像路径C:\\ xampp \\ htdocs \\ worldi \\ app \\ images
$images_path = realpath(Yii::app()->basePath . '/../images');
$model->image->saveAs($images_path . '/' . $model->image);
Yii的做法是使用YiiBase :: getPathOfAlias()将别名转换为相应的路径。
Yii预定了这些别名
system: refers to the Yii framework directory;
zii: refers to the Zii library directory;
application: refers to the application's base directory;
webroot: refers to the directory containing the entry script file.
ext: refers to the directory containing all third-party extensions.
所以使用
$ imagePath = YiiBase :: getPathOfAlias(“webroot”)。'/ images';
会给你所需的结果。