Safari HTML5多文件上传错误的任何变通方法? [英] Any workarounds for the Safari HTML5 multiple file upload bug?

查看:295
本文介绍了Safari HTML5多文件上传错误的任何变通方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过数周的调整后,我终于放弃了。我无法修复我在safari上的多文件上传,这真的让我困扰,因为我的代码在其他浏览器上运行得非常完美,除了在safari上。然后我刚刚发现它不是我的代码有问题。它是一个Safari bug。 Safari 5.1。+无法读取html5多重属性(或类似的东西)。因此,用户无法使用多重上传功能,但可以正确上传单个文件。



几个讨论此问题的链接:



https://github.com/moxiecode/plupload/issues/363



safari中的文件输入大小问题,用于多个文件选择



似乎这个bug已存在很长时间了。所以我想知道是否有一些可用的解决方法,你们当中有些人可能知道吗?因为我找不到任何东西。我发现唯一可用的选项是不为Safari 5.1。+用户使用多个属性。你们有更好的想法吗?



更新



Safari 5.1.7 是Apple为Windows操作系统制作的最新版本。他们没有继续构建适用于Windows的Safari的当前版本。因为 Real Safari用户已更新到最新版本的浏览器(无事实),因此无需为我找到此错误的修复程序,并且只需单独上传那些仍在使用这个过时版本的人,不要牺牲你的应用程序的现代功能。

解决方案

这是一个古老的问题,但是...黑客类型的解决方法如下。



只需删除Safari的多个属性,将其变为MSIE< = 9小弟弟(非-XHR)。



其他浏览器不会受到影响。



当Safari最终解决问题时,所有人要做的就是删除这个hack :: code并返回标准输入代码。



这里是标准输入样本:

 
< input class =fileupload-inputtype =filename =files []multiple />

jQuery解决方案:



只需放置它在页面的某个地方,你有文件输入标签。



你可以在这里阅读更多内容:如何检测Safari,Chrome,IE,Firefox和Opera浏览器?

 
$(document).ready(function(){
if(Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor')> 0) ;
$('。fileupload-input')。removeAttr(multiple);
});

PHP解决方案



你需要一些代码到id浏览器我用了一个类,我在github(MIT)中得到一个
得到它: https://github.com/gavroche/php-browser

 
$ files ='< input class =fileupload -inputtype =filename =files []multiple />';
if(Browser :: getBrowser()=== Browser :: SAFARI){
$ files ='< input class =fileupload-inputtype =filename =files [] />';
}
echo $ files

这就是全部。


After weeks of tweaking I finally gave up. I just couldn't fix my multiple file upload on safari, which really bothered me because my code worked perfectly as it should on other browsers, except on safari. Then I have just recently discovered that its not my code that has the problem. Its a Safari bug. Safari 5.1.+ can't read the html5 multiple attribute (or something like that). So users can't use the multiple upload feature, BUT, can properly upload a single file.

few links that discuss the issue:

https://github.com/moxiecode/plupload/issues/363

file input size issue in safari for multiple file selection

It seems that this bug has been around for quite some time. So I was wondering if there are workarounds available for this at the moment that some of you maybe are aware of? Because I can't find any. The only option available i found is to NOT use multiple attribute for Safari 5.1.+ users. Do you guys have any better ideas?

UPDATE

Safari 5.1.7 is the last version Apple made for the Windows OS. They did not continue to build current versions of Safari for Windows. Finding a fix for this bug for me is not necessary since Real Safari users are updated to the latest version of the browser(no facts), and just give a separate upload for those who are still using this outdated version, to not sacrifice the modern features of your application.

解决方案

This is oldish question, but ... hack-type workaround is below.

Just remove multiple attribute for Safari, turnig it into MSIE<=9 little brother (non-XHR).

Rest of browsers will not be affected.

When Safari finally fixes problem, all you have to do is remove this hack::code and go back to standard input code.

here is standard input sample:

<input class="fileupload-input" type="file" name="files[]" multiple />

jQuery solution:

Just place it somewhere on a page, where you have files input tag.

you may read more here: How to detect Safari, Chrome, IE, Firefox and Opera browser?

$(document).ready(function () { 
    if (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor')>0);
         $('.fileupload-input').removeAttr("multiple");
});

PHP solution

you will need some code to id browser I used a class I got one in github (MIT) get it here: https://github.com/gavroche/php-browser

 $files = '<input class="fileupload-input" type="file" name="files[]" multiple />';
 if (Browser::getBrowser() === Browser::SAFARI) {
    $files = '<input class="fileupload-input" type="file" name="files[]" />';
 }
echo $files

That is all.

这篇关于Safari HTML5多文件上传错误的任何变通方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆