input type file in html code example

Example 1: input a file in html form

<form action="{% url 'submit' %}" method="POST" enctype="multipart/form-data">
        {% csrf_token %}
  		<div class="mb-3">
            <label for="formFile" class="form-label">Image</label>
            <input class="form-control" type="file" id="formFile" name="image" accept="image/*">
        </div>

        <button class="btn btn-outline-info" type="submit">Submit</button>
</form>

Example 2: input file define type

<input type="file" accept=".gif,.jpg,.jpeg,.png,.doc,.docx">

Example 3: input type file select only video

accept="video/mp4,video/x-m4v,video/*"

Example 4: how to take a file input in html form

<label for="myfile">Select a file:</label>
<input type="file" 
  id="myfile" name="myfile">

Example 5: specifying file types in html file input

<input id="fileSelect" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />

Tags:

Php Example