我正在使用plupload版本2.在Ruby on Rails应用程序中。浏览按钮(导致打开文件对话框的打开)在Safari中无效,但在Firefox和Chrome中一切正常。 以下是我的代码:
$(document).ready(function(){
var uploader = new plupload.Uploader({
runtimes : 'html5',
browse_button : 'upload-pinboard-pic',
container : 'uploader_contianer',
url : '/galleries',
filters : [{title : "Image files", extensions : "jpg,gif,png"}],
autostart : true,
multipart : true,
multipart_params : {'class_type': 'BoardPic',
'_http_accept': 'application/javascript',
'_method': 'post',
'action' : 'create',
'controller' :'galleries',
'<%= Rails.application.config.session_options[:key] %>' : encodeURIComponent('<%= u cookies[Rails.application.config.session_options[:key]] %>'),
'authenticity_token': '<%= form_authenticity_token %>'}
});
uploader.init();
uploader.bind('FilesAdded', function(up, files){
if (files[0].size>1048576){
uploader.splice();
$("#dialog-confirm span").html('Photo must be less than 1 MB');
$("#dialog-confirm").dialog({
autoOpen: false,
resizable: false,
modal: true,
buttons: {
"Ok": function() {
$("#dialog-confirm").dialog("close");
return false;
},
}
});
weunite_modal_dialog();
}
else{
$("#uploading_image").show();
up.start();
}
});
uploader.bind('FileUploaded', function(up, file, info){
jsonObject = jQuery.parseJSON(info["response"]);
$("#uploading_image").hide();
if (jsonObject['error']){
$("#dialog-confirm span").html(jsonObject['error']);
$( "#dialog-confirm" ).dialog({
autoOpen: false,
resizable: false,
modal: true,
buttons: {
"Ok": function(){
$('#dialog-confirm').dialog("close");
}
}
});
weunite_modal_dialog();
}else{
$("#uploaded-file").attr('src', jsonObject['orig_url']);
var url = jsonObject['orig_url'];
$('#board-image-file').val(url);
$("#newBoard-attachmentID").val(jsonObject['attachment_id']);
}
});
});
提前致谢。
答案 0 :(得分:0)
我不知道它是如何工作的我只是更改了类的值和浏览按钮元素的Id。可能是Id / class冲突的原因。