Skip to content
Snippets Groups Projects
Commit 5d7b1432 authored by nicrausaz's avatar nicrausaz
Browse files

fix file replace

parent 9f89e025
No related branches found
No related tags found
No related merge requests found
......@@ -293,16 +293,17 @@ function deletePostulation ($pdo, $id, $sciper, $rep1, $rep2) {
foreach ($filesToRemove as $key => $file) {
unlink($file['file_path']);
}
// delete applicant folder
$dir = dirname($file['file_path']);
rmdir($dir);
// delete files (DB only)
// delete files from DB
$sqlreq = "DELETE FROM file WHERE fk_applicant_id=:id";
$query = $pdo->prepare($sqlreq);
$query->bindParam(':id', $id, PDO::PARAM_STR);
$query->execute();
echo "delete :$id";
// delete applicant personal data
$sqlreq = "DELETE FROM applicant WHERE applicant_id=:id";
$query = $pdo->prepare($sqlreq);
$query->bindParam(':id', $id, PDO::PARAM_STR);
......@@ -484,8 +485,8 @@ function updatePostulation ($pdo, $posted_data) {
$file_data = getOneFile($pdo, $file['id'], $posted_data->id);
$extension = strtolower("." . pathinfo($file['name'])['extension']);
$filename = $key . $extension;
$oldpath = $file_data['file_path'];
$path = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file_data['file_path']) . $extension;
unlink($file_data['file_path']);
if (move_uploaded_file($file['tmp_name'], $path)) {
// success, update db
......@@ -495,11 +496,8 @@ function updatePostulation ($pdo, $posted_data) {
$query->bindParam(':file_name', $filename, PDO::PARAM_STR);
$query->bindParam(':file_id', $file_data['file_id'], PDO::PARAM_STR);
$query->execute();
// TODO: check if working
unlink($path);
}
}
// header('Location: viewpostulation.php');
}
#endregion
?>
\ No newline at end of file
......@@ -23,8 +23,8 @@
<?php
ini_set("display_errors", 0);
error_reporting(0);
// ini_set("display_errors", 1);
// error_reporting(E_ALL);
ini_set("display_errors", 1);
error_reporting(E_ALL);
require_once('configs/config.php');
require('configs/db.php');
if (!isset($_SESSION)) { session_start(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment