uploadphp
uploadphp
php
header('Content-Type: application/json');
// 1. Configure uploads
$targetDir = __DIR__ . '/uploads/';
$maxFileSize = 50 * 1024 * 1024; // 50MB
$allowedTypes = ['model/gltf-binary', 'application/octet-stream'];
try {
// 3. Validate upload
if (!isset($_FILES['model'])) {
throw new Exception('No file uploaded');
}
$file = $_FILES['model'];
if (!in_array($mimeType, $allowedTypes)) {
throw new Exception('Only GLB files are allowed');
}
// 6. Validate size
if ($file['size'] > $maxFileSize) {
throw new Exception('File exceeds 50MB limit');
}
// 9. Return success
echo json_encode([
'success' => true,
'fileUrl' => '/uploads/' . basename($targetPath)
]);