Primo commit: trasferimento del progetto PPEasy

This commit is contained in:
2024-09-18 10:30:50 +02:00
commit eb475f257e
4233 changed files with 1043848 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
include('include/headscript.php'); ?>
<?php
if (isset($_GET['idfile'])) {
$fileId = $_GET['idfile'];
if (isset($_GET['iddata_td'])) {
$idtd = $_GET['iddata_td']; // Usa una variabile diversa per iddata_td
if (isset($_GET['idtrf'])) {
$idtrf = $_GET['idtrf'];
// Recupera il nome del file usando l'ID dal database
// Assumi $conn come tua connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);
$stmt = $conn->prepare("SELECT filename_fileattached FROM tdfileattached WHERE idtdfileattached = ?");
$stmt->bind_param("i", $fileId);
$stmt->execute();
$result = $stmt->get_result();
if ($row = $result->fetch_assoc()) {
$filePath = 'uploadtddocuments/' . $row['filename_fileattached'];
// Cancella il file dal filesystem
if (unlink($filePath)) {
// File cancellato, ora rimuovi il record dal database
$stmt = $conn->prepare("DELETE FROM tdfileattached WHERE idtdfileattached = ?");
$stmt->bind_param("i", $fileId);
if ($stmt->execute()) {
// Success, reindirizza
header("Location: techdossier_start.php?idtd=" . $idtd . "&idtrf=" . $idtrf);
exit();
} else {
echo 'database_error';
}
} else {
echo 'file_delete_error';
}
} else {
echo 'file_not_found';
}
$stmt->close();
$conn->close(); // Chiudi la connessione
}
}
}
?>