Product: FILE uploads
This commit is contained in:
@@ -10,14 +10,14 @@
|
||||
|
||||
// Cleanup deleted files
|
||||
if ($id > 0) {
|
||||
$sql = "SELECT `files` FROM md_contact WHERE company_id = :company_id AND id = :id";
|
||||
$sql = "SELECT `contact_image` FROM md_contact WHERE company_id = :company_id AND id = :id";
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute([":company_id" => $company_id, ":id" => $id]);
|
||||
$uploader->cleanup($sth->fetchColumn(), $data['keep_files'] ?? '');
|
||||
}
|
||||
|
||||
// Upload new files
|
||||
$errors = $uploader->upload('contact_files');
|
||||
$errors = $uploader->upload('contact_image');
|
||||
if (!empty($errors)) {
|
||||
$answer["success"] = 0;
|
||||
$answer["message"] = $errors[0];
|
||||
@@ -52,7 +52,7 @@
|
||||
":shipping_location"=> $data["shipping_location"],
|
||||
":shipping_address" => $data["shipping_address"],
|
||||
":remark" => $data["remark"],
|
||||
":files" => $db_image_string,
|
||||
":contact_image" => $db_image_string,
|
||||
":status" => (int)$data["status"],
|
||||
":log" => json_encode($table_log),
|
||||
];
|
||||
@@ -68,7 +68,7 @@
|
||||
`shipping_location` = :shipping_location,
|
||||
`shipping_address` = :shipping_address,
|
||||
`remark` = :remark,
|
||||
`files` = :files,
|
||||
`contact_image` = :contact_image,
|
||||
`status` = :status,
|
||||
`log` = :log
|
||||
WHERE id = :id AND company_id = :company_id";
|
||||
@@ -76,10 +76,10 @@
|
||||
} else {
|
||||
$sql = "INSERT INTO md_contact
|
||||
(company_id, contact_name, tax_id, organization, branch, contact_type,
|
||||
billing_address, shipping_location, shipping_address, remark, files, status, log)
|
||||
billing_address, shipping_location, shipping_address, remark, contact_image, status, log)
|
||||
VALUES
|
||||
(:company_id, :contact_name, :tax_id, :organization, :branch, :contact_type,
|
||||
:billing_address, :shipping_location, :shipping_address, :remark, :files, :status, :log)";
|
||||
:billing_address, :shipping_location, :shipping_address, :remark, :contact_image, :status, :log)";
|
||||
}
|
||||
|
||||
$sth = $pdo->prepare($sql);
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
parallelUploads: 10,
|
||||
acceptedFiles: "image/*",
|
||||
addRemoveLinks: true,
|
||||
paramName: "contact_files"
|
||||
paramName: "contact_image"
|
||||
});
|
||||
});
|
||||
|
||||
@@ -168,8 +168,8 @@
|
||||
let files = myDropzone.getQueuedFiles();
|
||||
|
||||
files.forEach(function(file) {
|
||||
// Use 'contact_files[]' so PHP creates an array in $_FILES
|
||||
formData.append('contact_files[]', file);
|
||||
// Use 'contact_image[]' so PHP creates an array in $_FILES
|
||||
formData.append('contact_image[]', file);
|
||||
})
|
||||
|
||||
let keepFiles = [];
|
||||
@@ -237,8 +237,8 @@
|
||||
|
||||
let item = res.output;
|
||||
// 2. Handle files specifically (No loop needed for the row)
|
||||
if (item.files) {
|
||||
let fileArray = item.files.split(',');
|
||||
if (item.contact_image) {
|
||||
let fileArray = item.contact_image.split(',');
|
||||
|
||||
fileArray.forEach(function(fileName) {
|
||||
if (fileName.trim() !== "") {
|
||||
|
||||
Reference in New Issue
Block a user