limit file type on drag and drop area

Viewed 132

Is possible to limit the file type accepted from a drag and drop file input? I've replaced a classic bootstrap4 file input with a drag and drop area. I'm not creating a website but an electron app. At the moment I'm able to manage the files in vue before processing them on the main node process of the app but I have no idea of how to limit the file type that the user can select.

This is the old file input

<div class="custom-file">
    <input type="file" class="custom-file-input" multiple accept=".txt,.rtf,.doc,.docx,.odt,.xls,.xlsx,.ods,.ppt,.pptx,.odp,.pdf,.jpg,.jpeg,.png,.gif" ref="selectedFiles" @change="handleFiles()">
    <label class="custom-file-label" for="customFile">
        <span class="d-inline-block text-truncate w-75">Choose several files</span>
    </label>
</div>

As you can see I've used the accept attribute, maybe I can do the same with the drop area?

0 Answers
Related