dimanche 24 novembre 2019

Image store but not show proper path in laravel API

How can i store actually path in database and how can i fetch image in API? This is output of API in postman enter image description here

This is database which show store path of image but its wrong..

enter image description here

 public function store(Request $request)
    {
        
        $event = $request->all(); 
           if ($request->hasFile('file')) {
$destinationPath = public_path().'/public/img/';
$file = $request->file;
$fileName = time() . '.'.$file->clientExtension();
$file->move($destinationPath, $fileName);
$input['e_image'] = $fileName;
}

            // $return['success'] = true,
            // $return['data'] = $event,
            // $return['msg'] = "this is message ";
             $success['status'] = true;
             $success['data'] = [$event];
             $success['message'] ="Event created successfully!";
             // $success['event'] = $event;
             return response()->json($success); 
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire