title: RuntimeException SplFileInfo::getSize(): stat failed for... Laravel 4 upload image
body: <p>I work with <em>laravel 4 (last update)</em>, I create a <strong>form</strong> where we could <strong>upload an image</strong> (logo/avatar). I am on <strong>MAC OS,</strong> I use <strong>sublime Text 3</strong>, <strong>laravel</strong> and <strong>MAMP Applications</strong>. All my configuration is setting right, no running problems.</p>
  
  <p>My probleme is that I have this <strong>error</strong> when I submit the reaching fields from my form: <strong>RuntimeException
  SplFileInfo::getSize(): stat failed for /Applications/MAMP/tmp/php/phpRUJfMX</strong></p>
  
  <p>Here's the code from my form <strong>nameOfTheForm.blade.php</strong>:</p>
  
  <pre><code>@extends('layout.default')
  @section('title')
  Name Of My Project - EditProfile
  @stop
  
  @section('content')
  {{Form::open(array('url'=&gt;'uploadAvatar','files' =&gt; true))}}
  
  &lt;p&gt;
  {{Form::label('pseudo','pseudo (*): ')}}
  {{Form::text('pseudo',Input::old('nom'))}}
  &lt;/p&gt;
  @if ($errors-&gt;has('pseudo'))
  &lt;p class='error'&gt; {{ $errors-&gt;first('pseudo')}}&lt;/p&gt;
  @endif
  &lt;br&gt;
  &lt;br&gt;
  
  &lt;p&gt;
  {{Form::label('url_Avatar','Avatar: ')}}
  {{Form::file('url_Avatar',Input::old('Url_Avatar'))}}
  &lt;/p&gt;
  @if ($errors-&gt;has('url_Avatar'))
  &lt;p class='error'&gt; {{ $errors-&gt;first('url_Avatar')}}&lt;/p&gt;
  @endif
  &lt;br&gt;
  &lt;br&gt;
  
  &lt;p&gt;
  {{Form::submit('Validate your avatar')}}
  &lt;/p&gt;
  
  {{Form::close()}}
  @stop
  </code></pre>
  
  <p>Here's the code from my <strong>controller</strong>:</p>
  
  <pre><code>public function uploadAvatar() {
  
  
  //*****UPLOAD FILE (on server it's an image, on the DB it's an url*****
    $file = Input::File('url_Avatar');
  
    //set a register path to the uploaded file
    $destinationPath = public_path().'/upload/';
  
    //have client extension loaded file and set a random name to the uploaded file, produce a random string of length 32 made up of alphanumeric characters [a-zA-z0-9]
  
    $filename = $destinationPath . '' . str_random(32) . '.' . $file-&gt;getClientOriginalExtension();
  
    $uploaded = Input::File('url_Avatar')-&gt;move($destinationPath,$filename);
  
  //*****VALIDATORS INPUTS and RULES*****
    $inputs = Input::all();
    $rules = array(
      'pseudo' =&gt; 'required|between:1,64|unique:profile,pseudo',
      //urlAvatar is an url in database but we register as an image on the server
      'url_Avatar' =&gt; 'required|image|min:1',
    );
  </code></pre>
  
  <p>The uploaded file code works perfect, I register the file in the selected folder I want. I Have no problem with my routes (no need to show this part of the code).</p>
  
  <p>But When I submit the form, I have this error:
  <strong><em>RuntimeException</em></strong>
  <strong>SplFileInfo::getSize(): stat failed for /Applications/MAMP/tmp/php/phpRUJfMX</strong></p>
  
  <p><em>error info details:</em>
  <strong><em>open:/Applications/MAMP/htdocs/nameOfMyProject/vendor/laravel/framework/src/Illuminate/Validation/Validator.php</em></strong></p>
  
  <pre><code>    }
      elseif (is_array($value))
      {
          return count($value);
      }
      elseif ($value instanceof File)
      {
          return $value-&gt;getSize() / 1024;
      }
      else
  </code></pre>
  
  <p>It seems, that Laravel needs (stat - Gives information about a file), that is to say, needs to have the informations from the uploaded file, here the size, but I try this in my controller just before the line where here's $uploaded where I move the file in my selected folder:</p>
  
  <pre><code>//I add this line code before
  $size= $file-&gt;getSize();
  $uploaded=Input::File('url_Avatar')-&gt;move($destinationPath,$filename);
  </code></pre>
  
  <p>But, when I did that, I have another error: the validator doesn't r**ecognize the files as an image** et ask me to upload <strong>a valid format</strong>. I think I need to correct the first errors I had <strong>(SplFileInfo::getSize())</strong></p>
  
  <p>If you have any ideas... Thank you.</p>