title: Unable to upload image in Laravel: "The "C:\xampp\tmp\php38A9.tmp" file does not exist or is not readable."
body: <p>So I'm trying to upload an image on update() function and it keeps giving me "C:\xampp\tmp\php38A9.tmp" file does not exist or is not readable." error. Following is my code: </p>
  
  <p><strong>EditForm.blade.php</strong> (Form with the Image Input):</p>
  
  <pre><code>{!! Form::model(Auth::user(),array('route'=&gt;['profile.update',Auth::user()-&gt;id],'method'=&gt;'PUT','files'=&gt;'true')) !!}
                      &lt;div class="form-group form-row"&gt;
                          &lt;div class="col"&gt;
                          {!! Form::text('fname',null,['class'=&gt;'form-control','placeholder'=&gt;'Enter First Name']) !!}
                          &lt;/div&gt;
                          &lt;div class="col-5"&gt;
                              &lt;div class="custom-file"&gt;
                              {!! Form::file('img',['class'=&gt;'custom-file-input']) !!}
                              {!! Form::label('Choose Avatar',null,['class'=&gt;'custom-file-label']) !!}
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          {!! Form::text('lname',null,['class'=&gt;'form-control','placeholder'=&gt;'Enter Last Name']) !!}
                          &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                           {!! Form::email('email',null,['class'=&gt;'form-control','placeholder'=&gt;'Enter Email']) !!}
                              &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                          {!! Form::password('password',['class'=&gt;'form-control','placeholder'=&gt;'Enter Student Password']) !!}
                              &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                          {!! Form::text('name',null,['class'=&gt;'form-control','placeholder'=&gt;'Enter Student Username']) !!}
                      &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                              {!! Form::number('rollno',null,['class'=&gt;'form-control','placeholder'=&gt;'Enter Roll Number']) !!}
                          &lt;/div&gt;
                      &lt;div class="form-group"&gt;
                     {!! Form::select('class', [
                      '1st' =&gt; '1st',
                      '2nd' =&gt; '2nd',
                      '3rd' =&gt; '3rd',
                      '4th' =&gt; '4th',
                      '5th' =&gt; '5th',
                      '6th' =&gt; '6th',
                      '7th' =&gt; '7th',
                      '8th' =&gt; '8th',
                      '9th' =&gt; '9th',
                      '10th' =&gt; '10th',],
                       null, ['class'=&gt;'custom-select','placeholder' =&gt; 'Choose Student Class']); !!}
                       &lt;/div&gt;
                       &lt;div class="form-group py-4"&gt;
                          {!! Form::submit('Create',['type'=&gt;'submit','class'=&gt;'btn btn-danger btn-block']) !!}
                            &lt;/div&gt;
                      {!! Form::close() !!}
  </code></pre>
  
  <p><strong>ProfileController.php</strong>:</p>
  
  <pre><code>class ProfileController extends Controller
  {
      /**
       * Display a listing of the resource.
       *
       * @return \Illuminate\Http\Response
       */
      public function index()
      {
          $users = User::all();
          return view('myprofile',compact('users'));
      }
  /**
   * Show the form for creating a new resource.
   *
   * @return \Illuminate\Http\Response
   */
  public function create()
  {
      //
  }
  
  /**
   * Store a newly created resource in storage.
   *
   * @param  \Illuminate\Http\Request  $request
   * @return \Illuminate\Http\Response
   */
  public function store(Request $request)
  {
      //
  }
  
  /**
   * Display the specified resource.
   *
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function show($id)
  {
      //
  }
  
  /**
   * Show the form for editing the specified resource.
   *
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function edit(User $user)
  {
      $user = User::all();
      return view('editprofile',compact('user'));
  
  }
  
  /**
   * Update the specified resource in storage.
   *
   * @param  \Illuminate\Http\Request  $request
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function update(User $user, FileRequest $request)
  {
      if($request-&gt;hasfile('img')){
          //getting the file from view
          $image = $request-&gt;file('img');
          $image_size = $image-&gt;getClientSize();
  
          //getting the extension of the file
          $image_ext = $image-&gt;getClientOriginalExtension();
          //changing the name of the file
          $new_image_name = rand(123456,999999).".".$image_ext;
          $destination_path = public_path('/images');
          $image-&gt;move($destination_path,$new_image_name);
  
          //saving file in database
          $user-&gt;image_name = $new_image_name;
          $user-&gt;image_size = $image_size;
          $user-&gt;save();
      }
      $user = Auth::user()-&gt;update($request-&gt;only(
      'fname',
      'lname',
      'name',
      'email',
      'password',
      'rollno',
      'class',));
      return redirect()-&gt;route('profile.index');
  }
  
  /**
   * Remove the specified resource from storage.
   *
   * @param  int  $id
   * @return \Illuminate\Http\Response
   */
  public function destroy($id)
  {
      //
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>FileRequest.php</strong> (Request to validate file types):</p>
  
  <pre><code>class FileRequest extends FormRequest
  {
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
          return true;
      }
  /**
   * Get the validation rules that apply to the request.
   *
   * @return array
   */
  public function rules()
  {
      return [
          'img' =&gt; 'mimes:jpeg,gif,png'
      ];
  }
  }
  </code></pre>
  
  <p><strong>Edit Button</strong> (This is the button that the user clicks to get to EditProfile.blade.php):</p>
  
  <pre><code> {{ link_to_route('profile.edit','Edit Profile',[Auth::user()-&gt;id],['class'=&gt;'btn btn-danger btn-block']) }}
  </code></pre>
  
  <p>So, when I upload the image and click Edit, it just gives me the error (I've attached a pictue of the error for everyone to see). Please let me know what I'm doing wrong here. Feel free to ask me to show more code if required.</p>
  
  <p><a href="https://i.stack.imgur.com/rKjec.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rKjec.png" alt="enter image description here"></a></p>