Perbaiki .gitignore agar log dan file sensitif tidak ikut commit

This commit is contained in:
WD - Dev
2025-10-18 16:05:45 +07:00
parent eb13c69431
commit 6017dfd369
27 changed files with 89223 additions and 280 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
header("Content-Type: application/json");
// direktori upload
$uploadDir = __DIR__ . "/../img/pesan/";
if (!file_exists($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
if (!isset($_FILES['file'])) {
echo json_encode(["status" => "error", "message" => "No file uploaded"]);
exit;
}
$file = $_FILES['file'];
$ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
$allowed = ['jpg', 'jpeg', 'png', 'gif'];
if (!in_array($ext, $allowed)) {
echo json_encode(["status" => "error", "message" => "Invalid file type"]);
exit;
}
$newName = uniqid("img_") . "." . $ext;
$target = $uploadDir . $newName;
if (move_uploaded_file($file['tmp_name'], $target)) {
$url = "https://manjapro.net/img/pesan/" . $newName;
echo json_encode(["status" => "success", "url" => $url]);
} else {
echo json_encode(["status" => "error", "message" => "Failed to move file"]);
}
?>