推荐关注
› Meteor
› JSLint - a JavaScript code quality tool
› jsFiddle
› D3.js
› WebStorm
推荐书目
› JavaScript 权威指南第 5 版
› Closure: The Definitive Guide
sohu022

WebUploader 有没有办法用代码触发点击上传

  •  
  •   sohu022 · Oct 20, 2016 · 6105 views
    This topic created in 3634 days ago, the information mentioned may be changed or developed.
    RT , 试了一下发现不能触发,大家有没有什么办法?
    6 replies  •  2017-10-26 17:33:42 +08:00
    sohu022
        2
    sohu022  
    OP
       Oct 20, 2016
    @airycanon 我意思是触发点击按钮, 出现文件选择对话框 类似这样 http://jsfiddle.net/ebSS2/
    sohu022
        3
    sohu022  
    OP
       Oct 20, 2016
    @airycanon 应该没办法用代码触发。
    for example if you(the script) programmatically click the button in an ajax callback nothing will happen, but if you put the same line of code in an event handler that was raised by the user, it will work.
    airycanon
        4
    airycanon  
       Oct 20, 2016
    http://fex.baidu.com/webuploader/doc/index.html#WebUploader_Uploader_options
    这里写的很清楚,参数 pick 指定选择文件的按钮,请仔细阅读文档。
    airycanon
        5
    airycanon  
       Oct 20, 2016   ❤️ 1
    @sohu022 我才明白你的意思,没错,按钮的触发,只能由用户发起。
    hurrak
        6
    hurrak  
       Oct 26, 2017
    $('.webuploader-element-invisible').trigger('click');
    webuploader-element-invisible 是 div#picker 里面创建的 input[type=file] ,选择文件后会触发 webuploader 的后续事件。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2209 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 125ms · UTC 05:03 · PVG 13:03 · LAX 22:03 · JFK 01:03
    ♥ Do have faith in what you're doing.