Using HTML, users can upload files from their computer to a web page using the <input> element with the type="file" attribute.
File Upload Input: The <input type="file"> element is used in forms to allow users to select files from their local file system to be uploaded to a server.
Usage Example:
The
Canvas Element: The
Usage Example:
html
Copy code
<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 200, 100);
</script>
In this example, a red rectangle is drawn on a canvas element.
References:
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload File" name="submit">
In this example, users can choose a file from their computer and upload it to the specified server endpoint.
References:
MDN Web Docs on <input type="file">
W3C HTML Specification on File Upload