Image Upload API

Upload images via API or web interface

API Endpoint

POST /upload.php

Request Format

Send a JSON object with base64 encoded image or external URL:

{
  "image": "data:image/png;base64,iVBORw0KG...",
  "source_url": "https://example.com/image.jpg"
}

Note: Either image (base64) or source_url is required.

Response Format

{
  "success": true,
  "data": {
    "id": "IMG_abc123_1234567890",
    "filename": "IMG_abc123_1234567890.png",
    "original_name": "image.png",
    "mime_type": "image/png",
    "size": 102400,
    "uploaded_at": "2026-02-25 15:30:00",
    "url": "/images/IMG_abc123_1234567890.png"
  }
}

Example Usage

cURL

curl -X POST /upload.php \
  -H "Content-Type: application/json" \
  -d '{"image": "data:image/png;base64,..."}'

JavaScript

const response = await fetch('/upload.php', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ image: base64String })
});
const result = await response.json();

PHP

$ch = curl_init('/upload.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
  'image' => $base64Image
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Content-Type: application/json'
]);
$response = curl_exec($ch);

Web Upload

Upload an image directly from your device

Image Upload API © 2026