【问题标题】:Blueimp jQuery File Upload plugin - Over Quota Error when clicking 'Start Upload'Blueimp jQuery 文件上传插件 - 单击“开始上传”时出现超过配额错误
【发布时间】:2013-10-16 00:32:15
【问题描述】:

我正在使用 Blueimp 的 jQuery 文件上传插件,但无法让它工作。我在这个site 上使用它。我似乎可以添加文件,但是当我单击“开始上传”时,它会将我带到一个页面,上面显示“错误。超出配额。此应用程序暂时超出其服务配额。请稍后再试。”有人见过这个吗?

这是我的 HTML:

<form id="fileupload" action="//grk.co/test2/" method="POST" enctype="multipart/form-data">
        <!-- Redirect browsers with JavaScript disabled to the origin page -->
        <noscript><input type="hidden" name="redirect" value="http://grk.co/test2/"></noscript>
        <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
        <div class="row fileupload-buttonbar">
            <div class="col-lg-7">
                <!-- The fileinput-button span is used to style the file input field as button -->
                <span class="btn btn-success fileinput-button">
                    <i class="glyphicon glyphicon-plus"></i>
                    <span>Add files...</span>
                    <input type="file" name="files[]" multiple>
                </span>
                <button type="submit" class="tiny success start">
                    <i class="glyphicon glyphicon-upload"></i>
                    <span>Start upload</span>
                </button>
                <button type="reset" class="tiny secondary cancel">
                    <i class="glyphicon glyphicon-ban-circle"></i>
                    <span>Cancel upload</span>
                </button>
                <button type="button" class="tiny alert delete">
                    <i class="glyphicon glyphicon-trash"></i>
                    <span>Delete</span>
                </button>
                <input type="checkbox" class="toggle">
                <!-- The loading indicator is shown during file processing -->
                <span class="fileupload-loading"></span>
            </div>
            <!-- The global progress information -->
            <div class="col-lg-5 fileupload-progress fade">
                <!-- The global progress bar -->
                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                    <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                </div>
                <!-- The extended global progress information -->
                <div class="progress-extended">&nbsp;</div>
            </div>
        </div>
        <!-- The table listing the files available for upload/download -->
        <table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
    </form>

还有我的 JS:

<script>
/*jslint unparam: true */
/*global window, $ */
$(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    var url = window.location.hostname === '91.208.99.4' ?
                '//grk.co/test2/' : 'server/php/';
    $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo('#files');
            });
        },
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('#progress .progress-bar').css(
                'width',
                progress + '%'
            );
        }
    }).prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>

如果有人能发现任何错误,我将不胜感激。我对 jQuery 很陌生,所以我肯定错过了一些东西。

如果需要更多信息,请告诉我。

【问题讨论】:

  • 更新 URL,但现在只是重定向到 index.html 而不是转到超额页面。我不确定我应该使用哪个 URL。显然我不知道我在做什么。有人帮忙吗?

标签: javascript jquery html jquery-plugins blueimp


【解决方案1】:

您在服务器上的上传处理脚本在哪里?目前(在您链接的示例页面上)上传的文件正在发送到http://grk.co/test2/server/php/。我猜这不是你想要的,因为 /server/php/ 只是 blueimp 包提供的默认值。您需要指向您自己的上传处理脚本。

【讨论】:

  • 我的 UploadHandler.php 位于 server/php/。我现在已经在 js 中正确地指出了它,但是你知道我在哪里更改 url 以指向我希望上传文件进入的文件夹吗?此外,进度条仍然什么也不做。上传的文件正在进入一个文件夹,但不是我想要的。
  • 上传文件的保存位置由UploadHandler.php中的代码控制。寻找 move_uploaded_file(foo,bar)。栏将是文件移动的位置。进度条对我来说更难调试。但是你需要progressall:function(e,data){}吗?我会尝试将其取出(连同完成后的逗号:函数{}),看看会发生什么。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-17
  • 1970-01-01
  • 2011-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多