Hi,
My chrome seems doesn't recognize the xls file. When I use file.type to get the mime type of xls file, it always return emtpy.
But it works for other files like xlsx, doc file.
Follow is my javascript code:
------------------------------------------------------------------------------------
function filechanged() {
var form = document.getElementById('TForm')
var file = form.getElementsByClassName('real-file-upload')[0].files[0];
//alert(
file.name)
//alert(file.type)
document.getElementById('FileName').textContent=
file.name document.getElementById('FileType').textContent=file.type
}
------------------------------------------------------------------------------------
Complete code is as follows:
------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<title>test upload</title>
<script>
function filechanged() {
var form = document.getElementById('TForm')
var file = form.getElementsByClassName('real-file-upload')[0].files[0];
//alert(
file.name)
//alert(file.type)
document.getElementById('FileName').textContent=
file.name document.getElementById('FileType').textContent=file.type
}
</script>
</head>
<body>
<form id='TForm'>
<input type='file' class='real-file-upload' onchange="filechanged()"/>
<br />
</form>
<br />
<label>File Name:</label><span id='FileName'></span>
<br />
<label>File type:</label><span id='FileType'></span>
</body>
</html>
------------------------------------------------------------------------------------
How can I solve this problem?
And can I get the file type list supported by my Chrome?
However, I found that Chrome on some other mac do support the xls file. I wonder why the behavior is not the same. Can there any reason can cause the difference.
My mac version is Sierra 10.12.6, Chrome version is 61.0.3163.79.
Thanks very much