文件上传控件在 Facebook 应用内浏览器中不起作用 [英] File upload control not working in Facebook In-App Browser
问题描述
我有一个移动 html Facebook 应用程序,它具有上传文件的控件(一个简单的输入文件).当我在类似 apps.facebook.com/myapp 的浏览器中打开应用程序时,我可以正常上传.但是一旦我通过原生 Facebook 应用程序并将我的应用程序加载到新 FB 的内部浏览器中,上传控件就不起作用了.它在页面上,但什么也不做.
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/myapp. But once I go through the native Facebook app and load my app in the new FB's internal browser, the upload control doesn't work. It's there on the page but does nothing.
- 这是预期的行为吗?
- 如果是这样,我该如何解决?
- 我可以强制在 Chrome 等外部浏览器中打开应用吗?
谢谢.
推荐答案
我们通过在 input 元素上添加Multiple"属性解决了这个问题.这似乎是 Facebook 浏览器中的一个错误.
We have fixed this problem by adding a "Multiple" attribute on the input element. It appears to be a bug in the Facebook browser.
这在 iOS 上修复了它,但我们有一些报告说它在 Android 中仍然无法正常工作.它还添加了一项检查以查看他们是否上传了多个文件(因为这可能不是故意的,但元素允许).希望能帮到你.
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");
}
});
}
这篇关于文件上传控件在 Facebook 应用内浏览器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!