Fix: Use absolute paths for all upload directories in processor files
- upload_profile_picture.php: Use absolute path for profile picture uploads, store relative path in DB - submit_pop.php: Use absolute path for proof of payment uploads - process_signature.php: Use absolute path for signature uploads, store relative path in DB
This commit is contained in:
@@ -26,11 +26,11 @@ if (isset($_POST['signature'])) {
|
|||||||
|
|
||||||
// Create a file path for the signature image
|
// Create a file path for the signature image
|
||||||
$fileName = 'signature_' . $user_id . '.png';
|
$fileName = 'signature_' . $user_id . '.png';
|
||||||
$filePath = 'uploads/signatures/' . $fileName;
|
$filePath = $rootPath . '/src/processors/uploads/signatures/' . $fileName;
|
||||||
|
|
||||||
// Ensure the directory exists
|
// Ensure the directory exists
|
||||||
if (!is_dir('uploads/signatures')) {
|
if (!is_dir($rootPath . '/src/processors/uploads/signatures')) {
|
||||||
mkdir('uploads/signatures', 0777, true);
|
mkdir($rootPath . '/src/processors/uploads/signatures', 0777, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the image file
|
// Save the image file
|
||||||
@@ -41,9 +41,12 @@ if (isset($_POST['signature'])) {
|
|||||||
die(json_encode(['status' => 'error', 'message' => 'Database connection failed']));
|
die(json_encode(['status' => 'error', 'message' => 'Database connection failed']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store relative path for HTML display
|
||||||
|
$display_path = 'src/processors/uploads/signatures/' . $fileName;
|
||||||
|
|
||||||
// Update the signature and indemnity acceptance in the membership application table
|
// Update the signature and indemnity acceptance in the membership application table
|
||||||
$stmt = $conn->prepare("UPDATE membership_application SET sig = ?, accept_indemnity = 1 WHERE user_id = ?");
|
$stmt = $conn->prepare("UPDATE membership_application SET sig = ?, accept_indemnity = 1 WHERE user_id = ?");
|
||||||
$stmt->bind_param('si', $filePath, $user_id);
|
$stmt->bind_param('si', $display_path, $user_id);
|
||||||
|
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
// Check the payment status
|
// Check the payment status
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$target_dir = "uploads/pop/";
|
$target_dir = $rootPath . "/src/processors/uploads/pop/";
|
||||||
$randomFilename = $validationResult['filename'];
|
$randomFilename = $validationResult['filename'];
|
||||||
$target_file = $target_dir . $randomFilename;
|
$target_file = $target_dir . $randomFilename;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] !=
|
|||||||
|
|
||||||
// Extract validated filename
|
// Extract validated filename
|
||||||
$randomFilename = $validationResult['filename'];
|
$randomFilename = $validationResult['filename'];
|
||||||
$target_dir = "assets/images/pp/";
|
$target_dir = $rootPath . "/assets/images/pp/";
|
||||||
$target_file = $target_dir . $randomFilename;
|
$target_file = $target_dir . $randomFilename;
|
||||||
|
|
||||||
// Ensure upload directory exists and is writable
|
// Ensure upload directory exists and is writable
|
||||||
@@ -48,6 +48,9 @@ if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] !=
|
|||||||
// Set secure file permissions (readable but not executable)
|
// Set secure file permissions (readable but not executable)
|
||||||
chmod($target_file, 0644);
|
chmod($target_file, 0644);
|
||||||
|
|
||||||
|
// Store relative path for HTML display
|
||||||
|
$display_path = "assets/images/pp/" . $randomFilename;
|
||||||
|
|
||||||
// Update the profile picture path in the database
|
// Update the profile picture path in the database
|
||||||
$sql = "UPDATE users SET profile_pic = ? WHERE user_id = ?";
|
$sql = "UPDATE users SET profile_pic = ? WHERE user_id = ?";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
@@ -57,9 +60,9 @@ if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] !=
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->bind_param("si", $target_file, $user_id);
|
$stmt->bind_param("si", $display_path, $user_id);
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
$_SESSION['profile_pic'] = $target_file;
|
$_SESSION['profile_pic'] = $display_path;
|
||||||
$response['status'] = 'success';
|
$response['status'] = 'success';
|
||||||
$response['message'] = 'Profile picture updated successfully';
|
$response['message'] = 'Profile picture updated successfully';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user