feat: complete WebGIS implementation with nominal bantuan and cache busting
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// ================================================================
|
||||
// API: File Upload
|
||||
// ================================================================
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
require_once __DIR__ . '/../includes/functions.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
jsonResponse(['success' => false, 'message' => 'Method harus POST'], 405);
|
||||
}
|
||||
|
||||
if (empty($_FILES['file'])) {
|
||||
jsonResponse(['success' => false, 'message' => 'Tidak ada file yang diupload'], 400);
|
||||
}
|
||||
|
||||
$file = $_FILES['file'];
|
||||
$prefix = sanitize($_POST['prefix'] ?? 'upload');
|
||||
$filename = handleUpload($file, $prefix);
|
||||
|
||||
if (!$filename) {
|
||||
jsonResponse(['success' => false, 'message' => 'Upload gagal. Pastikan tipe file dan ukuran sesuai (maks 10MB, tipe: jpg/jpeg/png/gif/pdf/doc/docx)'], 422);
|
||||
}
|
||||
|
||||
jsonResponse([
|
||||
'success' => true,
|
||||
'filename' => $filename,
|
||||
'url' => UPLOAD_URL . $filename,
|
||||
'message' => 'File berhasil diupload',
|
||||
]);
|
||||
Reference in New Issue
Block a user