0

我正在以这种方式加载精细上传器:

var uploader = new qq.FineUploaderBasic({
                button: $("#docAddHref"),
                request: {
                    endpoint: 'server/handleUploads'
                },
                validation: {
                    allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
                    sizeLimit: 204800 // 200 kB = 200 * 1024 bytes
                },
                callbacks: {
                    onSubmit: function (id, fileName) {
                        $messages.append('<div id="file-' + id + '" class="alert" style="margin: 20px 0 0"></div>');
                    },
                    onUpload: function (id, fileName) {
                        $('#file-' + id).addClass('alert-info')
                                        .html('<img src="client/loading.gif" alt="Initializing. Please hold."> ' +
                                              'Initializing ' +
                                              '“' + fileName + '”');
                    },
                    onProgress: function (id, fileName, loaded, total) {
                        if (loaded < total) {
                            progress = Math.round(loaded / total * 100) + '% of ' + Math.round(total / 1024) + ' kB';
                            $('#file-' + id).removeClass('alert-info')
                                            .html('<img src="client/loading.gif" alt="In progress. Please hold."> ' +
                                                  'Uploading ' +
                                                  '“' + fileName + '” ' +
                                                  progress);
                        } else {
                            $('#file-' + id).addClass('alert-info')
                                            .html('<img src="client/loading.gif" alt="Saving. Please hold."> ' +
                                                  'Saving ' +
                                                  '“' + fileName + '”');
                        }
                    },
                    onComplete: function (id, fileName, responseJSON) {
                        if (responseJSON.success) {
                            $('#file-' + id).removeClass('alert-info')
                                            .addClass('alert-success')
                                            .html('<i class="icon-ok"></i> ' +
                                                  'Successfully saved ' +
                                                  '“' + fileName + '”' +
                                                  '<br><img src="img/success.jpg" alt="' + fileName + '">');
                        } else {
                            $('#file-' + id).removeClass('alert-info')
                                            .addClass('alert-error')
                                            .html('<i class="icon-exclamation-sign"></i> ' +
                                                  'Error with ' +
                                                  '“' + fileName + '”: ' +
                                                  responseJSON.error);
                        }
                    },
                    onError: function (id, name, reason, xhr) {
                        $('#fubErrorAlert .message').text(reason);

                        $('#fubErrorAlert button').click(function () {
                            $('#fubErrorAlert').hide();
                        });

                        $('#fubErrorAlert').show();
                    }
                }
            });
            console.log('uploader called');
            uploader();

当页面加载我得到这个 javascript 错误:

无法读取未定义的属性“不透明度”

我通过 Nuget Pacakage for ASP.NET 安装了 FineUploader

https://github.com/Widen/fine-uploader-server/tree/master/ASP.NET%20MVC%20C%23

请指教!

4

1 回答 1

1

您的按钮选项可能是问题所在。您应该将其更改为:

button: $("#docAddHref")[0]

如果你想做一些事情,比如传入一个 jQuery 对象,你需要下载并使用 Fine Uploader 的 jQuery 插件。有关该插件的更多信息,请访问http://docs.fineuploader.com/integrating/jquery.html

于 2013-08-28T12:44:32.663 回答