![html5 file upload example html5 file upload example](https://freshdesignweb.com/wp-content/uploads/Bootstrap-file-input-style-demo.jpg)
This technology (Ajax) enables us to get data to the web server without having to use the POST requests and reload the web page for the new content and similarly it also enables us to send any data to the server, such as files, images and other data, to the web server. An Ajax request is an asynchronous request to the server to get some resources from the server and display it in the web page without needing to reload the web page.
#Html5 file upload example code
In JavaScript, we can shorten the code for creating an Ajax request. This option also minimizes the chances for error for any file that was triggered in the old methods and the user was informed of those errors after he uploaded all of the HTTP request data. You can manage which file to upload and which one to reject. But he can still view the results and other associated data, such as form elements and the result window.īut these are also old now, JavaScript is strong enough to upload your files and using HTML5 you can easily work your way with the validations of files too. Which means that if the form is submitted using an iframe then the main page the user is at is never submitted. The iframe is just another HTML document embedded in your main HTML document that if even navigated to any other web page it doesn't trigger a navigation event in the main page. Well before HTML5, people used hidden iframes to target the form to be uploaded from. The web is changing and there are many new ways for a user to upload an image or file to the server, without having to submit the form as he did back in 90s. Sometimes, the connection is lost and other stuff! This is a bit irritating and awkward, because the user uploaded more like 5 photos among them with one getting an error and the remaining 4 were also discarded and the user was told after 2 minutes to upload the 4 photos only and not that one specific image.
![html5 file upload example html5 file upload example](https://miro.medium.com/max/560/1*wQBmttmJ_xGgtNxIWZjmgA.png)
That would let them select a file and then they will click on the Submit button that would then take them to a new page, where they will be shown the message, “Your photos have been uploaded”, or an error message telling them that there was an error. In the old days, people would create a simple HTML form and assign the enctype to it. Most websites use HTML5 and jQuery plugins to upload files without requiring the user to send a POST request to the server but that is not a productive way to upload files.