File upload control not working in Facebook In-App Browser

后端 未结 6 1443
北恋
北恋 2020-12-08 05:41

I have a mobile html Facebook app which has a control to upload files (a simple input file). I can upload fine when I open the app in a browser like this apps.facebook.com/m

6条回答
  •  难免孤独
    2020-12-08 06:23

    For me the problem was the accept attribute of the file input.

    This doesn't work on native Facebook browser on mobile devices:

    accept=".jpg,.jpeg,.png,.svg,.tiff,.bmp,.webp,.bpg"

    So my solution was to detect if its a native FB browser, and remove that attribute:

    let isFacebookApp = function () {
        let ua = navigator.userAgent || navigator.vendor || window.opera;
        return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1);
    };
    
    if (isFacebookApp) {
       $('#myinput').removeAttr('accept');
    }
    

提交回复
热议问题