fix: Q&A 파일 업로드 권한 오류 수정

This commit is contained in:
root
2026-08-27 16:57:49 +09:00
parent ed4edccc54
commit ac9a784f7e
4 changed files with 38 additions and 23 deletions
+14 -10
View File
@@ -62,16 +62,20 @@ if ($isEdit) {
}
// === 파일 업로드 처리 공통 함수 ===
function handle_file_uploads(PDO $pdo, int $postId, array &$errors) {
if (empty($_FILES['attach']['name'][0])) return;
$uploadDir = __DIR__ . '/../uploads/qa/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
if (!is_writable($uploadDir)) {
@chmod($uploadDir, 0777);
}
function handle_file_uploads(PDO $pdo, int $postId, array &$errors) {
if (empty($_FILES['attach']['name'][0])) return;
$uploadDir = dirname(__DIR__) . '/uploads/qa';
if (!is_dir($uploadDir)) {
if (!mkdir($uploadDir, 0777, true) && !is_dir($uploadDir)) {
$errors[] = '업로드 폴더를 생성할 수 없습니다.';
return;
}
}
if (!is_writable($uploadDir)) {
@chmod($uploadDir, 0777);
clearstatcache(true, $uploadDir);
}
if (!is_writable($uploadDir)) {
$errors[] = '업로드 폴더에 쓰기 권한이 없습니다.';
return;