Modern Drag & Drop Upload
Modern Upload Features
This demo showcases modern file upload features including:
- Drag & Drop - Drag files directly into the upload zone
- Multiple Files - Upload multiple files at once
- AJAX Upload - Uploads happen in the background without page refresh
- Progress Tracking - Real-time upload progress indicators
- Image Previews - See thumbnails before and after upload
- Client-side Validation - Instant feedback on file type and size
Upload Files
Max 3 files | JPG/PNG only | Max 2MB per fileDrag & Drop Files Here
or click to browse
JPG or PNG, max 2MB each (0/3)
No files uploaded yet. Use the drag & drop zone above to upload your first files.
Implementation Details
// Client-side drag & drop handling
dropZone.addEventListener('drop', (e) => {
e.preventDefault();
const files = e.dataTransfer.files;
uploadFiles(files);
});
// AJAX upload with progress tracking
function uploadFiles(files) {
const formData = new FormData();
formData.append('file', file);
fetch(uploadUrl, {
method: 'POST',
body: formData,
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
showSuccess('File uploaded successfully!');
location.reload(); // Refresh to show new file
} else {
showError(data.error);
}
});
}
Features Demonstrated
- HTML5 Drag & Drop API - Native browser drag-and-drop support
- FileReader API - Client-side image preview before upload
- FormData API - AJAX file upload without form submission
- Fetch API - Modern promise-based HTTP requests
- Progressive Enhancement - Falls back to standard file input
- Responsive Design - Works on desktop and mobile devices
Browser Support
This demo uses modern web APIs supported by all current browsers:
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
Troubleshooting
Drag & Drop not working?
If drag and drop isn't working in Chrome/Edge, browser extensions may be blocking drag events:
- Test in Incognito Mode: Press Ctrl+Shift+N (Windows/Linux) or Cmd+Shift+N (Mac) to open an incognito window where extensions are disabled
- Common culprits: Ad blockers (uBlock Origin, AdBlock Plus), privacy extensions (Privacy Badger, Ghostery), or security extensions
- Solution: Go to
chrome://extensions/and disable extensions one by one to identify which one is blocking drag events - Alternative: Click the drop zone to use the traditional file picker instead

