added feature to save image into database and after upload it can be chose by dropdown
This commit is contained in:
@@ -104,6 +104,11 @@ $(document).ready(function () {
|
||||
const selector = $('<select id="photoSelector"></select>');
|
||||
photos.forEach((photo, index) => {
|
||||
const option = $('<option></option>').val(photo).text(`Photo ${index + 1}`);
|
||||
// display option with photo name if available
|
||||
if (photo.includes("/")) {
|
||||
const photoName = photo.split("/").pop();
|
||||
option.text(`Photo ${index + 1} - ${photoName}`);
|
||||
}
|
||||
selector.append(option);
|
||||
});
|
||||
|
||||
@@ -637,23 +642,34 @@ $(document).ready(function () {
|
||||
|
||||
const dataURL = canvas.toDataURL("image/png");
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
||||
const defaultName = `photo_${$("#partsModal").data("iddatadb")}_${timestamp}.png`;
|
||||
const iddatadb = $("#partsModal").data("iddatadb"); // 🟢 ეს გადავაგზავნოთ
|
||||
const defaultName = `photo_${iddatadb}_${timestamp}.png`;
|
||||
|
||||
const newName = prompt("Inserisci il nome del file (senza estensione):", defaultName.split(".png")[0]);
|
||||
|
||||
if (newName) {
|
||||
const finalName = newName + "_" + timestamp + ".png";
|
||||
$.ajax({
|
||||
url: "save_annotated_photo.php",
|
||||
method: "POST",
|
||||
data: { dataURL: dataURL, filename: finalName },
|
||||
data: {
|
||||
dataURL: dataURL,
|
||||
filename: finalName,
|
||||
iddatadb: iddatadb // 🟢 გადავცემთ PHP–ს
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.success) {
|
||||
alert("Foto salvata con successo: " + response.file_path);
|
||||
// update photo list or refresh the modal
|
||||
$("#samplePhoto").attr("src", response.file_path);
|
||||
loadPhoto(iddatadb); // reload to update markers
|
||||
clearCanvasMarkers(); // reset markers after save
|
||||
} else {
|
||||
alert("Errore nel salvataggio: " + response.message);
|
||||
alert("Errore: " + response.message);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
alert("Errore nel salvataggio della foto: " + error);
|
||||
alert("Errore Ajax: " + error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user