Really no different then a single upload just use a foreach Loop. And a search will reveal this has been answered before. asomething like
public function add() {
if (isset($_POST['submit'])) {
$lid = DB::table('recents')->count();
$k = -1;
if (empty($lid) || strlen($lid) == 0 || is_null($lid)) {
$lid = 1;
}
$newname = '';
$destinationPath = ROOTDIR . 'upload/imgrecent/';
$files = Input::file('ufile');
//$names = [];
$arrname = [];
foreach ($files as $file) {
$k = $k + 1;
if (empty($file)) {
$arrname[$k] = "";
} else {
$file_name = $file->getClientOriginalName();
$file_ext = $file->getClientOriginalExtension();
$lid = $lid + $k + 1;
$fileInfo = pathinfo($file_name);
$filename = $fileInfo['filename'];
print_r($filename);
$arrname[$k] = $filename . $lid . "." . $file_ext;
$file->move($destinationPath, (string) $arrname[$k]);
}
}
// more code to do the insert
like, but use laravel request, just quick example
$pic1 = Cln::fixValue((string) $arrname[0]);
$pic2 = Cln::fixValue((string) $arrname[1]);
$pic3 = Cln::fixValue((string) $arrname[2]);
$pic4 = Cln::fixValue((string) $arrname[3]);
$comments = Cln::fixValue($_POST['comments']);
if (!isset($error)) {
$postdata = array(
'pic1' => $pic1,
'pic2' => $pic2,
'pic3' => $pic3,
'pic4' => $pic4,
'comments' => $comments
);
DB::table('recents')->insert($postdata);
}
}//end add