简体   繁体   English

怎么做<input type="file">只接受 .py 和 .json 文件

[英]How to make <input type="file"/> accept only .py and .json files

I am trying to import only.py and.json file, and passing accept as text/x-python-script, application/json, text/x-python我正在尝试仅导入 .py 和 .json 文件,并将接受作为text/x-python-script、application/json、text/x-python传递

In windows OS, only .json files are able to get imported not the python file.在 windows 操作系统中,只能导入.json文件,而不是python文件。

Pass the filename extension for python files instead of the MIME type传递 python 文件的文件扩展名而不是 MIME 类型

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM