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
+35
View File
@@ -0,0 +1,35 @@
<?php
include('include/headscript.php'); ?>
<?php
if (isset($_POST['fileId'])) {
$fileId = $_POST['fileId'];
// 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()) {
// echo 'success';
} else {
echo 'database_error';
}
} else {
echo 'file_delete_error';
}
} else {
echo 'file_not_found';
}
$stmt->close();
}