Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
hasFile function not working in laravel 5.4

i am trying to upload a photo using Image Intervention Package i tried dd($request->hasFile('avator') ) and it return false i returned "error" in my if statment just to make sure that i have an error thanks in advance

public function update_photo(Request $request){ 
    if($request->hasFile('avator') ){
        $avator = $request->file('avator');
        $filename = time() . '.' . $pic->getClientOriginalExtension();
        Image::make($avator)->resize(300 , 300)->save(public_path('/uploads/avators' . $filename));
        $user = Auth::user();
        $user->avator = $filename ; 
        $user->save();
        echo "hello world !";
    }else {
        echo " Error"; // just to make sure that i have an error
    }
    return view("profile" , array("user" => Auth::user() ));

}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

first edit this line of code

$filename = time() . '.' . $avator->getClientOriginalExtension();

add to this slash also

Image::make($avator)->resize(300 , 300)->save(public_path('/uploads/avators/' . $filename));

*in your blade template make sure of spelling you are writing avator not avatar *

<input type="file" name="avator"/>
over 4 years ago · Santiago Trujillo Report

0

In your blade put this in your form tag:

enctype="multipart/form-data

and in your controller:

use File;  
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!