2012-01-15 10 views
4

私はローカルサイトの画像パスに画像をアップロードする必要があります。 どのように私はパスを書くことができますか?Yiiローカルファイルパスにアップロード

エラー: $ model-> image-> saveAs( '/ app/images');

画像パス C:\ xamppの\ htdocsに\ worldi \アプリ\画像YiiBaseを使用することになり、それを行うための

答えて

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

のYii道::その対応するパスにエイリアスを翻訳getPathOfAlias()。
Yiiはあなたが結果を必要となります

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

を使用して、これらの別名

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. 

を事前に定義します。

関連する問題