title: yii 2 upload file failed to open stream: No such file or directory
body: <p>I have problem with uploading image, it show me this error.</p>
  
  <blockquote>
    <p>move_uploaded_file(C:\AppServ\www\testyii\basic/uploadedfiles/1.jpg):
    failed to open stream: No such file or directory</p>
  </blockquote>
  
  <p>According the book I added This code.</p>
  
  <pre><code>'aliases' =&gt;
  [
  '@uploadedfilesdir' =&gt; '@app/uploadedfiles'
  ],
  </code></pre>
  
  <p>in $config array in basic/config/web.php and created folder uploadFiles in basic directory</p>
  
  <p>This is MODEL</p>
  
  <pre><code>&lt;?php
  namespace app\models;
  
  use yii\base\Model;
  
  class Room extends Model
  {
      public $floor;
      public $room_number;
      public $has_condition;
      public $has_tv;
      public $has_phone;
      public $available_from;
      public $price_per_day;
      public $description;
  
      public $fileImage;
  
      public function rules()
      {
          return [
              ['floor','integer','min'=&gt;0],
              ['room_number','integer','min'=&gt;0],
  
         [['has_condition','has_tv','has_phone'],'integer','min'=&gt;0,'max'=&gt;1],
              ['available_from','date','format'=&gt;'php:Y-m-d'],
              ['price_per_day','number','min'=&gt;0],
              ['description','string','max'=&gt;500],
  
              ['fileImage','file']
          ];
      }
  
      public function attributeLabels()
      {
              return [
              'floor' =&gt; 'Floor',
              'room_number' =&gt; 'Room number',
              'has_condition' =&gt; 'Condition available',
              'has_tv' =&gt; 'TV available',
              'has_phone' =&gt; 'Phone available',
              'available_from' =&gt; 'Available from',
              'price_per_day' =&gt; 'Price (EUR/day)',
              'description' =&gt; 'Description',
              'fileImage' =&gt;'Image',
              ];
      }
  
  
  }
  ?&gt;
  </code></pre>
  
  <p>This is CONTROLLER</p>
  
  <pre><code>&lt;?php
  
  
  namespace app\controllers;
  
  use Yii;
  use yii\web\Controller;
  use app\models\Room;
  use yii\web\UploadedFile;
  
  class RoomsController extends Controller
  {
      public function actionCreate()
      {
          $model=new Room();
          $modelCanSave=false;
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())&amp;&amp;$model-&gt;validate())
          {
              $model-&gt;fileImage = 
  UploadedFile::getInstance($model,'fileImage');
  
  
              if($model-&gt;fileImage){
  
                  $model-&gt;fileImage-&gt;saveAs(Yii::getAlias('@uploadedfilesdir/' 
  .$model-&gt;fileImage-&gt;baseName. '.' . $model-&gt;fileImage-&gt;extension));
  
                  //$model-&gt;fileImage-
  &gt;saveAs(Yii::getAlias('@uploadedfilesdir/' . $model-&gt;fileImage-&gt;baseName. 
  '.' . 
   $model-&gt;fileImage-&gt;extension));
                  //$model-&gt;fileImage-&gt;saveAs('@uploadFiles/' . $model-
  &gt;fileImage-&gt;baseName. '.' . $model-&gt;fileImage-&gt;extension);
  
                  }
              $modelCanSave=true;
          }
  
          return $this-&gt;render('create',
  ['model'=&gt;$model,'modelCanSave'=&gt;$modelCanSave]);
  
      }
  }
  ?&gt;
  </code></pre>
  
  <p>and VIEW</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\helpers\Url;
  use yii\helpers\ArrayHelper;
  use yii\widgets\ActiveForm;
  ?&gt;
  
  &lt;?php if($modelCanSave) { ?&gt;
  &lt;div class="alert alert-success"&gt;
  Model ready to be Saved!!
  &lt;/div&gt;
  &lt;?php } ?&gt;
  
  &lt;?php $form=ActiveForm::begin();?&gt;
  &lt;div class="row"&gt;
  &lt;div class="col-lg-12"&gt;
  &lt;h1&gt;Room form&lt;/h1&gt;
  &lt;?= $form-&gt;field($model,'floor')-&gt;textInput()?&gt;
  &lt;?= $form-&gt;field($model,'room_number')-&gt;textInput()?&gt;
  &lt;?= $form-&gt;field($model, 'has_condition')-&gt;checkbox() ?&gt;
  &lt;?= $form-&gt;field($model, 'has_tv')-&gt;checkbox() ?&gt;
  &lt;?= $form-&gt;field($model, 'has_phone')-&gt;checkbox() ?&gt;
  &lt;?= $form-&gt;field($model, 'available_from')-&gt;textInput() ?&gt;
  &lt;?= $form-&gt;field($model, 'price_per_day')-&gt;textInput() ?&gt;
  &lt;?= $form-&gt;field($model, 'description')-&gt;textarea() ?&gt;
  
  &lt;?= $form-&gt;field($model, 'fileImage')-&gt;fileInput()?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
  &lt;?=Html::submitButton('Create',['class'=&gt;'btn btn-success'])?&gt;
  &lt;/div&gt;
  
  &lt;?php ActiveForm::end();?&gt;
  
  &lt;?php if($modelCanSave) { ?&gt;
  &lt;div class="alert alert-success"&gt;
  Model ready to be saved!
  &lt;br /&gt;&lt;br /&gt;
  These are values: &lt;br /&gt;
  Floor: &lt;?php echo $model-&gt;floor; ?&gt; &lt;br /&gt;
  Room Number: &lt;?php echo $model-&gt;room_number; ?&gt; &lt;br /&gt;
  Has conditioner: &lt;?php echo Yii::$app-&gt;formatter-&gt;asBoolean($model-
  &gt;has_condition); ?&gt; &lt;br /&gt;
  Has TV: &lt;?php echo Yii::$app-&gt;formatter-&gt;asBoolean($model-&gt;has_tv); ?&gt; &lt;br/&gt;
  Has phone: &lt;?php echo Yii::$app-&gt;formatter-&gt;asBoolean($model-&gt;has_phone); ?&gt; 
  &lt;br /&gt;
  Available from (mm/dd/yyyy): &lt;?php echo Yii::$app-&gt;formatter-&gt;asDate($model-
  &gt;available_from,'php:m/d/Y'); ?&gt; &lt;br /&gt;
  Price per day: &lt;?php echo Yii::$app-&gt;formatter-&gt;asCurrency($model-
  &gt;price_per_day,'EUR'); ?&gt; &lt;br /&gt;
  Image:&lt;?php if(isset($model-&gt;fileImage)) { ?&gt; &lt;img src="&lt;?php echo 
  Url::to('@uploadedfiledir/'.$model-&gt;fileImage-&gt;name)?&gt;"/&gt;
  &lt;?php } ?&gt;
  &lt;/div&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>when Create button was clicked it show me like this.
  move_uploaded_file(C:\AppServ\www\testyii\basic/uploadedfiles/1.jpg): failed to open stream: No such file or directory</p>
  
  <p>Please help me solve this problem.
  Thank you very much.</p>