I am uploading multiple files with input box. I want to add that files in multiple rows with different id in mysql table.But its now working for me.
$paye_path=$obj->uploadMultiplePDF($_FILES['paye_inv'],$com_name);
above code works fine uploadMultiplePDF function is working for me.files are goes into my folder.
After this i am calling my insert function:
$query = $obj->insert_pay_slip_data($paye_path,$com_name);
it not working for me. this shows me below error:
Warning: Invalid argument supplied for foreach() in
Below is my insert query where i am using foreach loop:
public function insert_pay_slip_data($data,$com_name)
{
$con = $this->__construct();
$shareArray = array();
foreach($data as $shK=>$shVal)
{
$shareArray[$shK] = $shVal;
}
foreach ($shareArray as $keyshar => $valueshar)
{
$sql = "INSERT INTO `pay_slips`(`paye_id`, `trade_id`, `inv_pdf`, `created_date`,
`created_by`) VALUES (LAST_INSERT_ID(), '".$com_name."','".$valueshar['paye_path']."',NOW(),'".$_SESSION['email']."')";
$execute = mysqli_query($con, $sql);
return $execute;
}
}
In
inv_pdfcolumn file name should be come. and if i upload 5 files then 5 different rows should be created in table. But its not working. I might be wrong in foreach loop.
Array ( [0] => 1587701784152949112515934afa38db134c80f2444e07734a3f.pdf,21226947371529491125169512017.pdf )