Home > OS >  How to make <input type="file"/> accept only .py and .json files
How to make <input type="file"/> accept only .py and .json files

Time:12-01

I am trying to import only .py and .json file, and passing accept as text/x-python-script, application/json, text/x-python

In windows OS, only .json files are able to get imported not the python file.

CodePudding user response:

Pass the filename extension for python files instead of the MIME type

<input type="file" accept="application/json,.py" />

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers

  • Related