This is my function of inserting the images using dropzone but everytime I upload image it will insert a new id again it means new row..what I want is to upload all images in one row only and serialize all images.
<?php
if(!empty($_FILES)){
include 'connection.php';
$id = $_POST['id'];
$targetDir = "uploads/";
$fileName = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$img = $_FILES['file']['name'];
$img_name = $id . "_" . uniqid() . "_" . ($_POST['default_pic'] == $img ? "1" : "0") . "." . $fileName;
$targetFile = $targetDir.basename($img_name);
if(move_uploaded_file($_FILES['file']['tmp_name'],$targetFile)){
$new_data = array("cover" => ($_POST['default_pic'] == $img ? "1" : "0"), "img" => $img_name);
$new_array[] = $new_data;
$data_serialize = serialize($new_array);
//insert file information into db table
$conn->query("INSERT INTO files (file_name, uploaded) VALUES('".$data_serialize."','".date("Y-m-d H:i:s")."')");
}
}
?>
the use of my array there is to customize the name of image..and put them in one variable via functions serialize.
$new_data = array("cover" => ($_POST['default_pic'] == $img ? "1" : "0"), "img" => $img_name);
$new_array[] = $new_data;
Dropzone allows you to set "uploadMultiple" parameter.
http://www.dropzonejs.com/#config-uploadMultiple
When this is used, Dropzone will send all files in a single HTTP request, and you need to handle them on the backend side (PHP in your case). You should be able to see the format if you var_dump
your $_FILES
<script type="text/javascript">
$(function() {
var myDropzone = new Dropzone("#dz", {
uploadMultiple: true
});
});
</script>
and of course the HTML ...
<form id="dz"