최초 커밋

This commit is contained in:
root
2026-07-23 16:15:57 +09:00
commit c8f5efb6b7
14652 changed files with 4812531 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
header('Content-Type: application/json');
ini_set('display_errors', 0); // JSON 깨짐 방지
error_reporting(0);
$uploadDir = __DIR__ . '/../uploads/img/';
if (!is_dir($uploadDir)) mkdir($uploadDir, 0777, true);
if (!isset($_FILES['upload'])) {
echo json_encode(['uploaded' => false, 'error' => ['message' => '파일이 전송되지 않았습니다.']]);
exit;
}
$ext = strtolower(pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION));
$allowed = ['jpg','jpeg','png','gif','webp'];
if (!in_array($ext, $allowed)) {
echo json_encode(['uploaded' => false, 'error' => ['message' => '허용되지 않는 파일 형식입니다.']]);
exit;
}
$saveName = time().'_'.bin2hex(random_bytes(4)).'.'.$ext;
$savePath = $uploadDir.$saveName;
$url = '/eng/uploads/img/'.$saveName;
if (move_uploaded_file($_FILES['upload']['tmp_name'], $savePath)) {
echo json_encode([
"uploaded" => true,
"url" => $url
]);
} else {
echo json_encode([
"uploaded" => false,
"error" => ["message" => "파일 저장 실패"]
]);
}