plupload 多个 drop_elements

发布于 2024-12-21 03:49:41 字数 810 浏览 1 评论 0原文

我在一个页面上使用 Plupload,该页面将有多个 drop_elements 以及浏览按钮。我的问题是,默认情况下,使用 plupload 您可以为 drop_element 和 browser_button 定义一个元素,根据我阅读和尝试的内容,它只接受 1 个元素,而该元素恰好是该元素的 ID。

我需要以某种方式扩展它,以便我可以定义一个 id 数组或将其更改为类而不是 id。

var uploader = new plupload.Uploader({
        runtimes : 'gears,html5,flash,silverlight,browserplus',
        browse_button : **['ele_id1', 'ele_id2']**,
        drop_element : **['dropzone_id1', 'dropzone_id2']**,
        max_file_size : '200mb',
        url: '//senditfrom.me/fileupload/upload/do_upload',
        flash_swf_url: '//senditfrom.me/fileupload/js/plupload.flash.swf',
        silverlight_xap_url: '//senditfrom.me/fileupload/js/plupload.silverlight.xap',

        resize : {width : 320, height : 240, quality : 90}
    });

这可能吗?有没有人找到一种方法可以只定义 1 个元素?

I am using Plupload on a page that will have multiple drop_elements as well as browse buttons. My question is, by default with plupload you can define an element for both the drop_element and browse_button, from what i've read and tried it only accepts 1 element which happens to be an ID of that element.

I am needing to somehow extend this, so that I can define an array of id's or change it to be a class instead of an id.

var uploader = new plupload.Uploader({
        runtimes : 'gears,html5,flash,silverlight,browserplus',
        browse_button : **['ele_id1', 'ele_id2']**,
        drop_element : **['dropzone_id1', 'dropzone_id2']**,
        max_file_size : '200mb',
        url: '//senditfrom.me/fileupload/upload/do_upload',
        flash_swf_url: '//senditfrom.me/fileupload/js/plupload.flash.swf',
        silverlight_xap_url: '//senditfrom.me/fileupload/js/plupload.silverlight.xap',

        resize : {width : 320, height : 240, quality : 90}
    });

Is this possible? has anyone found a way around just being able to have 1 element defined?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

歌枕肩 2024-12-28 03:49:41

我知道这是一个老问题,但我遇到了有 2 个 browser_buttons 的问题,并找到了解决它的方法,我想在这里分享。

HTML:

<form id="uploader">
    <input type="button" class="pickfiles" id="0" value="Select 1"/>
    <input type="button" class="pickfiles" id="1" value="Select 2"/>
</form>

JS:

var uploader = new plupload.Uploader(
    {
        browse_button : '0',
        container : 'uploader',
    });

$('.pickfiles').mouseenter(function()
{
    uploader.settings.browse_button = $(this).attr('id'); //Assign the ID of the pickfiles button to pluploads browse_button
    uploader.refresh();
});

有关详细信息,请参阅下面的 jsfiddle。

http://jsfiddle.net/wLMNB/

I know this is an old question but I came across the problem of having 2 browse_buttons and found a way to solve it which I'd like to share here.

HTML:

<form id="uploader">
    <input type="button" class="pickfiles" id="0" value="Select 1"/>
    <input type="button" class="pickfiles" id="1" value="Select 2"/>
</form>

JS:

var uploader = new plupload.Uploader(
    {
        browse_button : '0',
        container : 'uploader',
    });

$('.pickfiles').mouseenter(function()
{
    uploader.settings.browse_button = $(this).attr('id'); //Assign the ID of the pickfiles button to pluploads browse_button
    uploader.refresh();
});

See the below jsfiddle for details.

http://jsfiddle.net/wLMNB/

小瓶盖 2024-12-28 03:49:41

我不确定自 David Healey 发布他的答案以来该插件是否已更改,但我发现他的答案只需稍加修改即可工作。

他的部分:

$('.pickfiles').mouseenter(function()
{
    uploader.settings.browse_button = $(this).attr('id'); //Assign the ID of the pickfiles button to pluploads browse_button
    uploader.refresh();
});

应该改为:

$('.pickfiles').mouseenter(function () {
            uploader.setOption("browse_button", $(this).attr('id')); //Assign the ID of the pickfiles button to pluploads browse_button
        });

很快就可以了!

I'm not sure if the plugin has changed since David Healey posted his answer but I found that his answer works with a small modification.

His section:

$('.pickfiles').mouseenter(function()
{
    uploader.settings.browse_button = $(this).attr('id'); //Assign the ID of the pickfiles button to pluploads browse_button
    uploader.refresh();
});

Should be changed to:

$('.pickfiles').mouseenter(function () {
            uploader.setOption("browse_button", $(this).attr('id')); //Assign the ID of the pickfiles button to pluploads browse_button
        });

And presto it works!

熊抱啵儿 2024-12-28 03:49:41

你可能需要破解该插件。在插件中,他们使用了 getElementById(browse_button) 您可以尝试将其更改为使用类。我还没有尝试过,但它可能会起作用。

you may have to hack the plugin. in plugin they have used getElementById(browse_button) you can try changing it to use class instead. i have not tried this but it may work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文