47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?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
|
|
}
|
|
}
|
|
}
|
|
?>
|