plupload smartphone and tablet browse button event not firing

妖精的绣舞 提交于 2019-12-22 10:22:13

问题


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>

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?


回答1:


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

https://stackoverflow.com/a/28592812/2282880



来源:https://stackoverflow.com/questions/36938051/plupload-smartphone-and-tablet-browse-button-event-not-firing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!