问题描述:

Hello I have been working in AngualarJS and using File UPload control which works completely fine. Now I have used FileAPI to make that working in IE8/9.

But now I want to detect if the browser support FormData because I want to restrict only one file at a time.But as I am using FileAPI the method window.FormData === undefined is not working as because of that I get something like this in IE8 :

function(){return{append:function(a,b,c){this.data.push({key:a,val:b,name:c})},data:[],__isShim:!0}}

How can I detect if the browser support FormData ?

网友答案:

Since you are using a shim and since your shim seems to return an object with a __isShim property with a value of true, you could check it like this:

var isFormDataSupported = window.FormData && !(new window.FormData()).__isShim;

Alternatively, you could check it before including your shim:

<script type="text/javascript">
    var isFormDataSupported = !!window.FormData;
</script>
<script src="src/to/your/shim.js"></script>
相关阅读:
Top