When creating a file select form in HTML, do you need a submit button?

Do you need to add a submit button to:
     <label for="file-select">Upload</label>
     <input type="file" name="upload" id="file-select">



Category: Development 9 months ago
Ryan M Dunnion
Asked 9 months ago
Ryan M Dunnion

The file select input only selects the file, it does not upload it.

In order to upload it you will need to pass the selected file to an upload function, usually after submitting the form (process it on the <form action="upload.php" method="post"> upload.php script). Thus, needing a submit button.

This can all be avoided however with the power of javascript. Using a javascript event such as onchange, one can upload the selected file without a submit button. The onchange event can call the functions needed to upload the file, and even populate a div with the uploaded picture once complete.

An example of a file uploading form without a submit button 

Important to understand is that html can not upload files.

Html is a client side code, meaning that it is for browsers.

To upload a file to a server, you will need a server side language to process the form input, such as php. Here's one tutorial about the html/php file upload form/function. To find out more, I suggest searches for 'html form file upload php' or some such.

I hope this was helpful. Let me know if you have any more questions, I'll be happy to clarify or answer anything I can.

Answered 9 months ago

Please register/login to answer this question.  Click here to login
Cron Job Starts