我在一个metronic bootstrap框架上使用plupload,在桌面上运行正常,但在智能手机或平板电脑上,我的浏览按钮无法打开窗口来选择文件。
<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脚本:
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();
});
我是否需要绑定一个特别针对移动的设备的活动,以便我的设备进行浏览?
1条答案
按热度按时间gmol16391#
我的解决方案是手动触发按钮上的事件:
https://stackoverflow.com/a/28592812/2282880