JD Detailing
Image Uploader Component Demo

Drag & Drop Image Uploader

Reusable component for uploading images with drag & drop functionality, preview grid, and file management

Try It Out!

Drag images from your computer or click to browse

Drag & drop images here

or click to browse

PNG, JPG, GIF up to 10MB • 10 of 10 slots available

How to Use

1

Drag & Drop

Drag image files from your computer and drop them onto the upload area.

2

Click to Browse

Click anywhere in the upload area or the "Select Files" button to open your file browser.

3

View & Manage

Preview uploaded images in the grid. Hover over an image to see the remove button.

4

Use URLs

Copy image URLs for use in your pages, or copy as background style code.

Component Props

onUploadComplete

Function called when upload finishes with image URLs array

onChange

Function called whenever images change (add/remove)

maxFiles

Maximum number of files allowed (default: 5)

showPreview

Show/hide image preview grid (default: true)

initialImages

Array of initial image URLs to display

className

Additional CSS classes for styling

Integration Examples

1. Basic Usage

import ImageUploader from '../components/ImageUploader';

function MyComponent() {
  const [images, setImages] = useState([]);

  return (
    <ImageUploader
      onUploadComplete={(imageUrls) => {
        setImages(imageUrls);
        console.log('Uploaded:', imageUrls);
      }}
      maxFiles={5}
      showPreview={true}
    />
  );
}

2. Use as Background Image

const [backgroundUrl, setBackgroundUrl] = useState('');

<ImageUploader
  onUploadComplete={(urls) => {
    if (urls.length > 0) {
      setBackgroundUrl(urls[0]); // Use first image
    }
  }}
  maxFiles={1}
/>

{/* Apply as background */}
<div
  style={{
    backgroundImage: `url(${backgroundUrl})`,
    backgroundSize: 'cover',
    backgroundPosition: 'center',
    minHeight: '400px'
  }}
  className="rounded-lg"
>
  {/* Your content here */}
</div>

3. With onChange Callback

<ImageUploader
  onChange={(updatedImages) => {
    // Called on every change (add/remove)
    console.log('Current images:', updatedImages);
  }}
  onUploadComplete={(newImages) => {
    // Called only when upload completes
    console.log('Upload finished:', newImages);
  }}
  maxFiles={10}
/>

4. Without Preview Grid

<ImageUploader
  onUploadComplete={(urls) => setImages(urls)}
  showPreview={false}
  maxFiles={3}
/>
/ 05 — Free Quote

Get My Free Quote

Priced to your vehicle — get a free quote in 30 seconds. Tell us your car and what it needs and we'll text you a personalized price.

(774) 446-0662Text us anytime

Mon–Sat 8AM–6PM · Sun by Appt

FULLY INSUREDWE BRING WATER & POWERHAND DETAILEDSATISFACTION GUARANTEED

/ Request your quote

Service(s)
Photos (optional, up to 5)

No obligation · We usually reply within 30 minutes

Your Car Deserves Better. Get Your Free Quote.

Mobile detailing — we come to you. Fully insured. Satisfaction guaranteed.