File uploading certain MIME Types
I'm trying to allow only .tsv files visible for upload. It's a valid MIME Type, so I'm not sure why it isn't working. Can you help?
<input type="file" accept="text/tab-separated-values" />
你可以尝试使用JavaScript。
<script type="text/javascript" language="javascript">
function checkfile(inputVal) {
var validExts = ".tsv";
var fileExt = inputVal.value;
fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
if (validExts.indexOf(fileExt) < 0) {
alert("Invalid file selected. ");
return false;
}
else return true;
}
</script>
嗯看看这个链接只是为了确保你的MIME类型是正确的
The Mime-Type tells the server which protocol to use to process the information given. I've always done this as validation on the server side by only accepting file name(s) that end with .tsv
If you do not want to do this server side, you can write some javascript to look at the value of the input field before you submit to make sure it ends with .tsv
链接地址: http://www.djcxy.com/p/45674.html上一篇: 使用Excel VBA关闭Powerpoint对象(不使用Powerpoint.Application)
下一篇: 文件上传某些MIME类型