checkbox values not being received in laravel controller

2145 views php
-2

I have this bit of code in my form edit.blade.php :

 @php
$imagepath="images/Service/".$services->name."/";
$images=glob($imagepath.'*.*');

@endphp

  <div class="row">
     @foreach($images as $image)
     @php
     $count++;
     @endphp
    <div class="col-md-5">
      <img src="{{URL::asset($image)}}"  >
    </div>
    <div class="col-md-1"><input form="services" type="checkbox"  name="deleteimagelink[]" value="{{($image)}}"  >

    </div>

          @endforeach

  </div>

This is for passing the path of those images meant to be deleted. And I have this snippet in my controller:

   print_r($request->input('deleteimagelink'));
$deletables=$request->input('deleteimagelink');
foreach ($deletables as $deletable)
    {
        print_r($deletable);
        unlink($deletable);

}

I have this problem that nothing is being received in the $request->input('deleteimagelink') parameter. Please guide me if I'm doing anything wrong. If nothing seems weird, can you please guide me how to deal with these checkbox situations in laravel. I consulted related answers from internet but nothing seems to work.

answered question

1 Answer

10

change name in input

<input form="services" type="checkbox"  name="deleteimagelink" value="{{($image)}}"  >

posted this

Have an answer?

JD

Please login first before posting an answer.