The HTML script below collects user information and files and posts to the database. the challenge is that when the files are multiple, it send the file path to different rows. please assist me to configure the upload file to send the file path for images per upload to one row. thank you.
HTML
Hotel Name * Town/City * "/> (+) Add fileUpload.php.
<?php
include ("connection.php");
if ($_POST["action"] == "Upload")
die ("Error: no files uploaded!");
$file_count = count($_FILES["item_file"]['name']);
echo $file_count . " file(s) sent... <BR><BR>";
if(count($_FILES["item_file"]['name'])>0) { //check if any file uploaded
for($j=0; $j < count($_FILES["item_file"]['name']); $j++) { //loop the uploaded file array
$filen = $_FILES["item_file"]['name'][$j];
// ingore empty input fields
if ($filen!="")
{
// destination path - you can choose any file name here (e.g. random)
$path = "images/" . $filen;
if(move_uploaded_file($_FILES["item_file"]['tmp_name']["$j"],$path)) {
echo "File# ".($j+1)." ($filen) uploaded successfully!<br>";
} else
{
echo "Errors occoured during file upload!";
}
//create array of temporarily grab variables
$input_arr=array();
//grabs the post variables and adds slashes
foreach($_POST as $key=> $input_arr){
$_POST[$key]=addslashes($input_arr);
}
mysql_select_db("fcom_com") or die("Could not select database");
mysql_query("INSERT INTO contri (field_1,field_2,URL)
VALUES('".$_POST['field_1']."','".$_POST['field_2']."','".$_FILES['item_file']['name']["$j"]."')");
}
}
}
?>