chend
V2EX  ›  问与答

问个 IE9 下 多文件 input:file 问题

  •  
  •   chend · Feb 10, 2017 · 3730 views
    This topic created in 3400 days ago, the information mentioned may be changed or developed.

    一个 input:file 按钮, 想多次 选择 文件,然后 在内存中 保存 这些文件 $('input:file')[0].files[0], 缓存到列表 fileList = [file1,file2], 然后 一个一个用 iframe 上传,但是 创建的 input:file 不能直接赋值为文件 file , 直接 clone() input 生成的也是没有 file 的。

    请问下 ,怎么 实现 这个缓存和 上传 ?

    Supplement 1  ·  Feb 11, 2017
    缓存方法知道了:
    因为安全机制, input:file 不能直接赋值为某个文件, 所以上传的文件是保存在操作的 input:file 中, 直接缓存这个 input:file DOM 就将包含的文件一起缓存了
    4 replies    2017-02-10 21:31:06 +08:00
    pubby
        1
    pubby  
       Feb 10, 2017
    每个 input:file 一个 form onchange 之后直接 form.submit 可以隐藏掉 form ,替换成 "正在上传"之类的

    然后第二个 form input:file .....

    十年前就是这么干的。。。
    pubby
        2
    pubby  
       Feb 10, 2017
    form 的 target 可以是一个隐藏的 iframe,在里面接收处理上传结果
    chend
        3
    chend  
    OP
       Feb 10, 2017
    @pubby 不是立即上传, 是维护一个列表, 可以进行删除处理, 最后再全部文件一起传
    pubby
        4
    pubby  
       Feb 10, 2017   ❤️ 1
    安全问题,file value 不能设置的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1433 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 17:09 · PVG 01:09 · LAX 10:09 · JFK 13:09
    ♥ Do have faith in what you're doing.