jeudi 7 mai 2020

Input type file is sending data as text

I have the following simple view file:-

<form action="" method="POST">
    
    <input type="file" name="avatar" >
    <input type="submit">
</form>

In Controller file i am suppose to receive a file type input, but i just get the image name as text:-

public function teststore(Request $request){
        dd($request->all());
        //returned array:2 [▼
        // "_token" => "jFPlhBHXP9jLXCJkrlDg62wR8eVaiBJgEnTD8wBZ"
        //"avatar" => "2.png"

       dd($request->has('avatar'));
       // returned true

       dd($request->hasFile('avatar');
       //returned null (Although the input type is "file")
  } 

Please advice



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire