Local File Support Detection in JavaScript - Windows Phone 8 Bug -


i have question <input type=file> html element -- specifically, why signs point being supported on windows phone 8 (ie 10 mobile), yet doesn't work.

i have been working on photo uploader project, , in javascript development, have logic in place check file api support, know if can support local file selection. surprisingly, code have in place returning true value on windows phone 8. shouldn't issue, <input type=file> element isn't supported wp 8 (as noted on windows blog in article ie 10 mobile). result on wp 8 if <input type=file> element on page, shows fine, nothing happens when clicking "browse" button.

my js code check file api support is:

function checklocalfilesupport() {    if (window.file && window.filereader && window.filelist && window.blob) {        return true;    }    return false; } 

i'm hoping shed light on how better check , confirm if local file selection available on specific device/browser. said, current solution returns true on wp 8. i've been trying variety of different methods see if <input type=file> enabled (snippets below), of other solutions still return true wp 8.

one caveat this: really want code device-agnostic. such, don't want have sniff browser user-agent. in mind, user-agent sniffing fallback i'd rather not have implement.

here few solutions i've found , tried, yet still return true on wp 8:

referencing disabled attribute on input element:

function isinputtypefileimplemented() {     var elem = document.createelement("input");     elem.type = "file";     if (elem.disabled) return false;     try {         elem.value = "test"; // throws error if type=file implemented         return elem.value != "test";     } catch(e) {         return elem.type == "file";     } } 

using jquery.support:

var support = (function(undefined) {     return $("<input type='file'>")    // create test element                  .get(0)               // native element                  .files !== undefined; // check whether files property not undefined })(); 

hopefully can shed light on how accurately wp 8 return false value local file support.

thanks in advance!

according this blog post systems return false positive support , can overcome checking them regexp such as

if (navigator.useragent.match(/(android (1.0|1.1|1.5|1.6|2.0|2.1))|(windows phone (os 7|8.0))|(xblwp)|(zunewp)|(w(eb)?osbrowser)|(webos)|(kindle\/(1.0|2.0|2.5|3.0))/)) {    return false; } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -