drop() is a p5.js element method that registers a callback every time a file is loaded into the element. The uploaded file is created into a p5.File class. You can use the drop() callback to check the file type, then write conditional statements responding to the file type.
Image Drop: Revised by Kasey Lichtlyter. Edited and maintained by p5.js Contributors and Processing Foundation. Licensed under CC BY-NC-SA 4.0.
You can find the code history of these examples here: 2023 code, pre-2023 code. You can suggest improvements by contributing to the current website!
Related Examples

A grey background with white text reading "Drag an image file onto the canvas."
Image Drop
Display an image that the page visitor dragged and dropped.

An input field with a submit button, labeled "Hello, p5!"
Input and Button
Use text input from the page visitor.

A survey on a yellow background, consisting of an input field, radio buttons, and a dropdown.
Form Elements
Create a form and respond to the results.