🚀 CDN Upload API

Secure image upload service with API key authentication

API Endpoint

POST https://cdn.domain.com/upload.php

This is an API-only service. No web UI for uploads.

Authentication

All requests require API key in headers:

Header Value
X-API-Key Your API key
Content-Type multipart/form-data

Request

Parameters

Parameter Type Description
file File Image file (JPG, PNG, WebP) • Max 5MB

Example cURL

curl -X POST https://cdn.domain.com/upload.php \
  -H "X-API-Key: your_api_key_here" \
  -F "file=@/path/to/image.jpg"

Example JavaScript

const formData = new FormData();
formData.append('file', fileInput.files[0]);

fetch('https://cdn.domain.com/upload.php', {
  method: 'POST',
  headers: { 'X-API-Key': 'your_api_key_here' },
  body: formData
})
.then(res => res.json())
.then(data => console.log(data));

Response

Success 201

{
  "success": true,
  "upload_id": 1,
  "filename": "proof_abc123_1234567890.jpg",
  "original_filename": "screenshot.jpg",
  "file_size": 123456,
  "mime_type": "image/jpeg",
  "url": "https://cdn.domain.com/uploads/proof_abc123_1234567890.jpg",
  "uploaded_at": "2025-10-29 14:37:44"
}

Error 4xx / 5xx

{
  "error": "Error message"
}

Error Codes

Code Description
400 Bad request (invalid file, size, or type)
401 Unauthorized (invalid or missing API key)
405 Method not allowed
500 Server error

Features

API Key authentication
File type validation (MIME + Extension)
File size limit (5MB)
Unique filename generation
Upload history tracking
IP address logging
CORS enabled

Rate Limits & Security

• Each API key is tracked individually

• Upload history logged with IP address

• Automatic file validation (type & size)

• Unique filename prevents overwrites

• Protected uploads directory

Need an API key? Contact administrator.
Documentation: README.md