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;