How can I check if the browser support HTML5 file upload (FormData object)?

后端 未结 7 1937
离开以前
离开以前 2020-12-08 04:38

How can I check if the browser support HTML5 file upload (FormData object)?

var fd = new FormData();

Following the answer from this post, b

7条回答
  •  生来不讨喜
    2020-12-08 05:00

    You need to check if the browser supports the HTML5 file API. I do that by checking if the FileReader function is set, if it’s not set it means that the browser won’t support the file API.

    // Check if window.fileReader exists to make sure the browser supports file uploads
    if (typeof(window.FileReader) == 'undefined') 
        {
            alert'Browser does not support HTML5 file uploads!');
        }
    

提交回复
热议问题