Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda