plupload smartphone and tablet browse button event

2019-05-12 00:52发布

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 ?

Thanks for help.

1条回答
The star\"
2楼-- · 2019-05-12 01:16

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

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

查看更多
登录 后发表回答