パブリックフォルダに複数のファイルをアップロードし、データベース内の複数のファイルパスをアップロードしたかったので、パブリックフォルダに複数のファイルをアップロードできましたが、複数のファイルパスをdbに保存できません。 1つのファイル名とパスのみがデータベースに格納されます。ビューの複数のファイルをlaravelのデータベースにアップロードする方法を教えてください。
:コントローラで
<form class="form-horizontal row-border" action="<?= URL::to('/checkiou') ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="file" name="attachments[]" multiple/>
<input name="save" type="submit" value="Save">
public function upload() {
// Request the file input named 'attachments'
// Request the file input named 'attachments'
$files = Request::file('attachments');
//If the array is not empty
if ($files[0] != '') {
foreach($files as $file) {
// Set the destination path
$destinationPath = 'uploads';
// Get the orginal filname or create the filename of your choice
$filename = $file->getClientOriginalName();
// Copy the file in our upload folder
$file->move($destinationPath, $filename);
}
$data1 = DB::table('tbl_iou')->max('iou_id');
$check=0;
$check=DB::table('tbl_iou')
->where('iou_id',$data1)
->update(array('image_path'=>$destinationPath, 'file_name'=>$filename));
if ($check > 0)
{
$_SESSION['msg']="Petty cash details saved Successfully";
return Redirect::to('iou_accounts');
}
}