File upload control not working in Facebook In-App Browser

后端 未结 6 1433
北恋
北恋 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

    We have fixed this problem by adding a "Multiple" attribute on the input element. It appears to be a bug in the Facebook browser.

    This fixes it for iOS, but we have had some reports of it not working still in Android. It also adds a check to see if they uploaded more than one file (since that may not be intended, but is allowed by the element). I hope it helps.

    if (navigator.userAgent.match(/FB/)) {
        $('#myinput').attr('multiple',true);
        $('#myinput').change(function(){
            if ($('#myinput')[0].files.length > 1) {
                //user trying to upload more than 1
                $('#myinput').value = '';
                alert("Sorry, only 1 file is allowed");
            }
        });
    }
    

提交回复
热议问题