本文介绍了plupload智能手机和平板电脑浏览按钮事件不解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在metronic bootstrap框架上使用plupload。在桌面上它工作正常但在智能手机或平板电脑上,我的浏览按钮没有打开窗口来选择文件。

I use plupload on a metronic bootstrap framework. On desktop it's working fine but on smartphone or tablet, my browse button is not opening the window to select files.

<div class="col-md-8">
    <div id="engine"></div>
    <div id="dev_uploader">
    <div id="filelist"></div>
</div>
<a id="addImg" class="btn btn-bg btn-block"><i class="fa fa-plus"></i> add attachement</a>

这里是plupload脚本:

here is the plupload script :

jQuery(function() {
    var uploader = new plupload.Uploader({
        runtimes : 'html5,flash,silverlight,gears',
        browse_button : 'addImg',
        container : 'dev_uploader',
        drop_element : 'dev_uploader',
        max_file_size : '10mb',
        chunk_size: '1mb',
        url : '/upload.php',
        flash_swf_url : '/js/plupload/Moxie.swf',
        silverlight_xap_url : '/js/plupload/Moxie.xap',
        filters : [{
            title : "Images",
            extensions : "jpg,png,pdf"
        }],
        dragdrop: true,
        multi_selection: false
    });

    uploader.bind('Init', function(up, params) {
        jQuery('#engine').html("Current runtime: " + params.runtime);

        if (uploader.features.dragdrop) {

            var target = $("devis_uploader");

            target.ondragover = function(event) {
                event.dataTransfer.dropEffect = "copy";
            };

            target.ondragenter = function() {
                this.className = "dragover";
            };

            target.ondragleave = function() {
                this.className = "";
            };

            target.ondrop = function() {
                this.className = "";
            };
        }

    });

    uploader.init();

    // identify image div to refresh
    uploader.bind('BeforeUpload', function (up, file) {
        uploader.settings.multipart_params = {
            site : '{$site.id}',
            page : 'tender',
            code : '{$newcode}',
            id   : file.id
        }
    });

    // after files added
    uploader.bind('FilesAdded', function(up, files) {
        imgs = files;
        jQuery.each(files, function(i, file) {
            //var ext = file.name.substr(file.name.lastIndexOf('.') + 1);
            jQuery('#filelist').append(
                '<div id="' + file.id
                + '" class="filethumb new"><span>'
                + '(' + plupload.formatSize(file.size)
                + ')</span> | <b>0%</b></div>'
            );
        });

        //uploader.settings.multipart_params["id"] = i;
        uploader.start();

        //e.preventDefault();
        up.refresh(); // Reposition Flash/Silverlight
    });

    uploader.bind('UploadProgress', function(up, file) {
        jQuery('#' + file.id + " b").html(file.percent + "%");
    });

    uploader.bind('Error', function(up, err) {
        if(err.file) {
            jQuery('#' + err.file.id).html('<i data-original-title="' + response.error.message +
            '" id="popinfo' + file.id + '" style="color: #CCC" class="fa fa-exclamation-triangle fa-4x" data-toggle="tooltip" data-placement="top" title=""></i>');
        }
        jQuery('#popinfo' + file.id).tooltip();
        up.refresh();
    });

    uploader.refresh();
});

我是否需要绑定特别针对移动设备的事件以供我的设备浏览?

Do I need to bind an event especially for mobile device for my device to browse ?

感谢您的帮助。

推荐答案

解决方案一直是我手动触发按钮上的事件:

The solution has been for me to trigg manually the event on the button :

这篇关于plupload智能手机和平板电脑浏览按钮事件不解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 15:12