Below is my code to upload images and update the database with the respective image names.
Upload is working fine but have some problems in syntax to update mysql database.
function storeimage()
{
$files = array();
$target_path1 = $_FILES['file1']['tmp_name'];
$target_path2 = $_FILES['file2']['tmp_name'];
$target_path3 = $_FILES['file3']['tmp_name'];
$files = array(1=>'file1',2=>'file2',3=>'file3');
//uploadimages($files)
//$target_path = "images/";
foreach($files as $data)
{
$target_path = $_FILES[$data]['name'];
if(move_uploaded_file($_FILES[$data]['tmp_name'], "images/".$target_path))
{
$publish = $_POST['publish'];
$databaseupdate = "INSERT INTO `uploadfiles`.`uploads`
(`id`, `name1`, `name2`, `name3`, `publish`)
VALUES (NULL, '$files['file1']','$files['file2']','$files['file3']','$publish')";
$mysqlupdate = mysql_query($databaseupdate);
echo "The file ". basename($_FILES[$data]['name']).
" has been uploaded<BR>";
}
else
{
echo "There was an error uploading the file, please try again!";
}
$target_path ="";
}
}