shakti's avatar

Multiple image problem

Hello guys

I have a strange problem

I m trying to upload multiple image till 25 ID its working fine but after that its not taking any value here is my view

<form action="{{url('/social/update')}}" method="post" id="socialupdate" name="socialupdate" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="hidden" id="actiontype" name="action" value="update">
<div class="table-responsive">
    <table class="table table-striped table-bordered text-right checkbox-tbl">
      @foreach($socials as $social)
      <tr>
        <td>

            <input type="hidden" name="id[]" value="{{$social->social_id}}"> 
            <table class="table sub-table">
              <tr>
                <td>

                <input type="checkbox" class="form-control social" name="social[{{$social->social_id}}]" id="social_{{$social->social_id}}" value="{{$social->social_id}}">

                <label for="social_{{$social->social_id}}"></label></td>
                <td><input type="text" class="form-control" name="title[{{$social->social_id}}]" id="title" value="{{$social->title}}"></td>

                <td><input type="text" class="form-control" name="url[{{$social->social_id}}]" value="{{$social->url}}"></td>

                <td><input type="file" class="form-control" name="imageicon[{{$social->social_id}}]"></td>

                <td><img src="{{ url('/storage/app/images/social/'.$social->image) }}" height="100" width="100" class="img-responsive" alt="image not exists"></td>

                <td>
                  <select class="form-control" name="is_active[{{$social->social_id}}]">
                    <option value="1" <?php if(isset($social->is_active) && $social->is_active == 1) echo "selected"; ?> >Active</option>
                    <option value="0" <?php if(isset($social->is_active) && $social->is_active == 0) echo "selected"; ?>>Inactive</option>
                  </select> 
                </td>

                <td><input type="button" onclick="SingleTaxonomiesAction('{{$social->social_id}}','update')" class="btn btn-warning" value="{{trans('messages.keyword_save')}}">

                <a onclick="conferma(event);" type="button" href="javascript:SingleTaxonomiesAction('{{$social->social_id}}','delete')" class="btn btn-danger"> {{trans('messages.keyword_delete_label')}}</a></td>

              </tr>
            </table>                    
          </td>
      </tr>
      @endforeach
    </table>
  </div>
</form>

here is my controller

 public function updatesocial(Request $request) 
    {
        
        dd($request->all());

        foreach($request->social as $key => $val) {   

            if($request->action == 'delete') {
                DB::table('social')->where('social_id', $key)->delete();
            } else {  
            $title = isset($request->title[$key]) ? $request->title[$key] : '';
            $image = isset($request->image[$key]) ? $request->image[$key] : '';
            $url = isset($request->url[$key]) ? $request->url[$key] : '';
            $is_active = isset($request->is_active[$key]) ? $request->is_active[$key] : 0;

            $image = DB::table('social')->select('image')
                ->where('social_id', $key)->first();

            $arr = json_decode(json_encode($image), true);              
            $imagename = $arr['image'];   
            $arrfiles = $request->file('image'); 

            if (isset($arrfiles[$key]) && $arrfiles[$key] != null) {            
                Storage::put('images/social/' . $arrfiles[$key]->getClientOriginalName(), file_get_contents($arrfiles[$key]->getRealPath()));                
                $imagename = $arrfiles[$key]->getClientOriginalName();
            }    
                DB::table('social')->where('social_id', $key)->update(array('title'=> $title, 'image' => $imagename, 'url' => $url, 
                    'is_active' => $is_active));
            }
        }

        $msg = ($request->action == 'delete') ? '<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> '.trans('messages.keyword_deletesuccessmsg').' </div>' : '<div class="alert alert-info"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a> '.trans('messages.keyword_editsuccessmsg').' </div>';

        return Redirect::back()->with('msg', $msg);
    } 
0 likes
4 replies
mushood's avatar
mushood
Best Answer
Level 41

Hello

Try having a look at your phpinfo(). There is a limit to the number of file uploads. Do ensure that this limit is not passed.

If i am not mistaken, the limit is called "max_file_uploads"

1 like

Please or to participate in this conversation.