p5.js | createFileInput() Function
The createFileInput() function is used to create an input element with the type of ‘file’ that can be used by the user to select local files to be used in the sketch. It also supports the selection of multiple files if required.
Parameters: This function accepts two parameters as mentioned above and described below:
- callback: It is the callback function that would be used when the file is loaded. It is an optional parameter.
- multiple: It is a string which specifies if multiple files are allowed to be selected at once. It can be set to “true” or “false”. It is an optional parameter.
Return Value: It returns a pointer to the p5.Element holding the created file object.
Below examples illustrate the createFileInput() function in p5.js:
Example 1: In this example, we will take one file as an input.
Example 2: In this example, we will take multiple files as an input.
Online editor: https://editor.p5js.org/