什么是在HTML5 [多]文件输入中选择的文件的最大数量? [英] What is the max number of files to select in an HTML5 [multiple] file input?

查看:179
本文介绍了什么是在HTML5 [多]文件输入中选择的文件的最大数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有64000个小图片要上传到我的网站(使用现有的验证,所以没有FTP等)。我已经为此创建了一个HTML5 [multiple] type = file输入,可以用于上百个或上百个图像。数百个不是问题。图片批量发送到服务器。

但是,当我选择一个约16000图像的文件夹时,文件输入的FileList为空... onchange事件触发器,但文件列表是空的。浏览器(或文件系统或操作系统?)似乎有一个问题,选择这么多的文件。



我创建了一个非常小的工具,以帮助确定可能是max: http://jsfiddle.net/rudiedirkx/Ehhk5/1/show/

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ p $变化=功能(e){
var l = 0,b = 0; (var i = 0,F = this.files,L = F.length; i l + = F [i] .name.length;
b + = F [i] .size;
}
$ nf.innerHTML + = this.files.length +'files:'+(b / 1000/1000)+'MB /'+ l +'chars of filename< br>
};

所有这些都是计数:


  • 文件数目

  • 所有文件名称被合并的字符数量
  • 文件总大小的MB数量



当我尝试这个时,我得到最多的:

$ (在32& 64位的Win7上,Chrome 26的b $ b

1272个文件:176.053987 MB / 31469字符的文件名




  • 下一张图片(失败) 1273张图片,在176到177 MB文件大小之间不是明显的截止点

  • ,也不是明显的截止点

  • 小于32000字符的文件名,也不是一个明显的截止,虽然它排序 - 也许看起来像32K ... ... $ / b>
    $ b

    在我calc ,1 MB = 1000 ^ 2字节,而不是1024 ^ 2。 (这将是一个MiB,但也许我的操作系统/文件系统/浏览器不同意。)

    我的问题是:为什么这么多文件?为什么这个最大?依赖操作系统还是依赖于浏览器?我在哪里可以找到这个规格?这是JS的错吗?搜索文件输入最大文件等只会导致[max]属性,这是不相关的。



    更多测试结果:


    • 在Firefox中,max似乎要高得多。至少2343个文件:310.66553999999996 MB / 60748字符的文件名(这是我在这里的所有文件)

    • 在Firefox中也:16686文件:55.144415 MB / 146224字符的文件名(更小,但更多的文件)



    更新


    • Chrome 52 canary Windows仍然是32k文件名

    • Firefox(44+)Windows仍然是无限制的

    解决方案


    为什么需要这么多文件?


    文件数量取决于所有文件名称合并的字符数量。


    为什么这个最大?

    在Windows API中,最大路径长度限制为256个字符,Unicode版本API为32,767个字符。 b
    $ b

    Chrome简单地设置了Unicode版本API的最大路径长度,因此您观察到的大约是32k个字符。

    检查此修复: https://code.google.com/p/chromium/issues/detail?id=44068
    检查这个修补程序: https://bugzilla.mozilla.org/show_bug.cgi?id=660833


    是依赖于操作系统还是依赖于浏览器?


    两者。


    找到那个规格?

    对于Windows API使用和引用:

    http://msdn.microsoft.com/zh-cn/library/aa365247.aspx (最大路径长度限制)

    http://msdn.microsoft.com/ en-us / library / ms646839(VS.85).aspx


    JS是错吗?


    不。


    I have 64000 small images I want to upload to my website (using existing validation, so no FTP etc). I've created an HTML5 [multiple] type=file input for this a while back to be used for a hundred or hundreds of images. Hundreds is not a problem. The images are batched and sent to the server.

    But when I select a folder of ~ 16000 images, the file input's FileList is empty... The onchange event triggers, but the file list is empty. The browser (or file system or OS?) seems to have a problem selecting this many files.

    I've created a very small tool to help determine what could be the max: http://jsfiddle.net/rudiedirkx/Ehhk5/1/show/

    $inp.onchange = function(e) {
        var l = 0, b = 0;
        for (var i=0, F=this.files, L=F.length; i<L; i++) {
            l += F[i].name.length;
            b += F[i].size;
        }
        $nf.innerHTML += this.files.length + ' files: ' + (b/1000/1000) + ' MB / ' + l + ' chars of filename<br>';
    };
    

    All it does is count:

    • the number of files
    • the number of characters all file names are combined
    • the number of MB of total file size

    When I try this, I get as very most:

    1272 files: 176.053987 MB / 31469 chars of filename

    (On 32 & 64 bit Win7, Chrome 26-52)

    The next image (which fails) would be:

    • 1273 images, which is not an obvious cut-off
    • between 176 and 177 MB filesize, also not an obvious cut-off
    • less than 32000 chars of filenames, also not an obvious cut-off, although it sort-of maybe looks like 32k...

    In my calc, 1 MB = 1000^2 Bytes, not 1024^2. (That would be a MiB, but maybe my OS/filesystem/browser disagrees.)

    My question would be: why this many files? Why this max? Is it OS dependent or browser dependent? Where do I find the specs for that? Is it JS' fault? Search for "file input max files" et al only results into the [max] attribute, which is irrelevant.

    More test results:

    • In Firefox the max seems to be much higher. At least "2343 files: 310.66553999999996 MB / 60748 chars of filename" (that's all the files I have right here)
    • In Firefox also: "16686 files: 55.144415 MB / 146224 chars of filename" (much smaller, but more files)

    Update

    • Chrome 52 canary Windows is still 32k of file name
    • Firefox (44+) Windows is still unlimited

    解决方案

    why this many files?

    The number of files depends on the number of characters all file names are combined.

    Why this max?

    In the Windows API, the maximum path length limitation is 256 chars, the Unicode version API is 32,767 chars.

    Chrome simply sets the max path length of the Unicode version API, so it's about 32k chars as you observed.
    Check this fix: https://code.google.com/p/chromium/issues/detail?id=44068

    Firefox dynamically allocates a buffer big enough to hold the size of multiple selected files, which could handle much larger path length.
    Check this fix: https://bugzilla.mozilla.org/show_bug.cgi?id=660833

    Is it OS dependent or browser dependent?

    Both.

    Where do I find the specs for that?

    For Windows API usage and reference:
    http://msdn.microsoft.com/en-us/library/aa365247.aspx (Maximum Path Length Limitation)
    http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx

    Is it JS' fault?

    No.

    这篇关于什么是在HTML5 [多]文件输入中选择的文件的最大数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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