2

我正在使用版本 2 的 plupload。在 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']);
                   }
            });
    });

提前致谢。

4

1 回答 1

0

我不知道它是如何工作的,我只是更改了类的值和浏览按钮元素的 Id。可能是身份/阶级冲突是原因。

于 2013-11-15T07:24:50.273 回答