1 year ago

Multiple image upload and Insert into multiple row of database...

Posted 1 year ago by amk

I want to upload multiple image but I don't want to insert image name in only one row of database. When I upload 4 photos,database must have 4 rows. Anyone can suggest me,how to fix this pls... IDK how to create multiple row of database from controller...

public function store(Request $request)
        $files = $request->file('file');
     foreach ($files as $file) {
         $filename = uniqid() . '_' . $file->getClientOriginalName();

     return redirect()->route('media.index');


That's from my view..

<form id="target" method="post" action="{{route('')}}" enctype="multipart/form-data">
     {{ csrf_field() }}
    <input type="file" name="file[]" id='fil' multiple> 
  $('#fil').change(function() {

Please sign in or create an account to participate in this conversation.