Laravel Api – multiple images upload (to use it with angular)

  angular, api, laravel

the problem is that the json array is inserted ,but it is empty
how can I solve this problem

——————- Laravel side ————————
this is the controller function

             public function storeImages(Request $request)

                $files = [];
                    foreach($request->file('images') as $file)     
                        $name = $file->getClientOriginalName() ;   
                        $file->move(public_path().'/images/' , $name);  
                        $files[] = $name;  
                  $file= new ImageAnnonce() ;
                  $file->annonceId = $request->annonceId;
                  $file->image_name =json_encode($files);

                  return response()->json(['message' => 'Images Uploaded Successfully']);

this is the route api

Route::post('storeImages',[AnnonceController::class, 'storeImages']);

this is the table

    public function up()
        Schema::create('image_annonces', function (Blueprint $table) {

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.