WebDAVJSON is a simple PHP/Node.js script that provides file management APIs. It supports CORS, optional API key authentication, upload with extension restrictions, and JSON response for file listing.
- CORS support
- Optional API key authentication
- File listing (JSON)
- File upload, download, and delete
- Extension restrictions
- Single-file program
winget install mkcert Node.js --silent
mkcert -install
mkcert localhost
node index.mjs
# await fetch('https://localhost:8443/').then(r=>r.json())
# await fetch('https://localhost:8443/?filename=foo.txt', {method: 'PUT', body: 'foobar'})wget https://raw.githubusercontent.com/GitHub30/WebDAVJSON/refs/heads/main/index.php| Method | Path | Description |
|---|---|---|
| GET | /?filename=abc.txt | Download file |
| GET | / | List files (JSON) |
| POST/PUT | / | Upload file |
| POST/PUT | /?filename=abc.txt | Binary upload |
| DELETE | /?filename=abc.txt | Delete file |
curl http://localhost/curl "http://localhost/?q=abc"curl -O http://localhost/?filename=abc.txtcurl -OJ "http://localhost/?download&filename=abc.txt"curl -F "file=@abc.txt" http://localhost/curl -X PUT --data-binary @abc.txt "http://localhost/?filename=abc.txt"const blob = await fetch($0.src).then(r=>r.blob())
await fetch('https://localhost:8443/?filename=image.png', {method: 'POST', body: blob})curl -X DELETE "http://localhost/?filename=abc.txt"If you set a value for $api_key in index.php, the header Authorization: Bearer <API_KEY> is required.
Example:
curl -H "Authorization: Bearer your_api_key" http://localhost/txt, jpg, png, webp, heic, gif, pdf, docx, xlsx, zip, mp4, gz
MIT