how do i write multiple files name to a mysql db at once after uploading images to a folder?
here is my code so far.
[php]
<?php
//Check if the form was submitted.
if(isset($_POST['uploadButton'])) {
//Specify folder path where the file is going.
$path = 'uploads/';
//Upload file one by one.
foreach($_FILES['file']['name'] as $key => $val) {
if($val != '') {
$file_name = $_FILES['file']['name'][$key]; //Get file name.
$file_tmp = $_FILES['file']['tmp_name'][$key]; //Get temporary file name.
$file = $path . $file_name;
//Move uploaded file
if(move_uploaded_file($file_tmp, $file)) {
echo 'File was succesfully uploaded to: ' . $file . '
';
} else {
//Display error message if there was a problem uploading file.
echo 'Error uploading file "' . $key . '."
';
}
echo $target_path;
$gallery = "upload/".basename( $_FILES['file']['name']);
echo $gallery;
$sql = "INSERT into images (imagePath) VALUES ('$gallery')";
mysql_query($sql) or die(mysql_error());
echo "Information added to the images table";
}
}
}
}
?>
[/php]