Photo Filter Website: Getting the Photos to Filter
Common ways to get photos into your app:
1. Upload from User’s Computer
Allow users to select a photo file from their device using an <input type="file"> element.
Example: Uploading and Displaying User’s Photo for Filtering
How This Works:
-
User clicks the upload input and selects a photo.
-
JavaScript reads the file and converts it to a data URL.
-
The
<img>element’ssrcis set to this URL, showing the photo. -
Now you can apply CSS filters or other effects to the loaded photo.
2. Use URLs or API to Load Photos
You can allow users to input a URL of an image or fetch images from online APIs (like Unsplash API) — then set those URLs to the image’s src.
3. Drag and Drop (Advanced)
Allow users to drag an image file onto a drop zone — read the file with similar FileReader logic.
Full Mini Example with Upload + Filter Sliders
Summary
-
Use
<input type="file">to let users upload photos. -
Use
FileReaderAPI to read files and convert to image source URLs. -
Once loaded, apply your CSS filters dynamically.
-
Optionally, enhance UX with drag-and-drop or URL input features.
