(JQuery文件上传)maxFileSize表现得很奇怪

时间:2016-09-11 23:15:48

标签: jquery

我的选择是以一种奇怪的方式表现,我无法弄清楚它是否使用了我不知道的单位,或者它是否只是简单的窃听。

例如,将其设置为12000允许我上传约50ko但不是〜120ko的文件,而将其设置为15000则允许我上传850ko文件。

它似乎也取决于文件的类型(有时会上传850ko png,而不会上传850ko jpg)。

有人知道问题可能是什么吗?

$('#fileupload').fileupload({
    acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
    maxFileSize: 12000,
    progressInterval: 10,
    disableImageResize: false,
    imageMinWidth: 150,
    imageMaxWidth: 150,
    imageMinHeight: 150,
    imageMaxHeight: 150,
    imageCrop: true,
    processfail: rest of the code...


<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
        <script src="/core/scripts/blueimp/js/vendor/jquery.ui.widget.js"></script>
        <!-- The Load Image plugin is included for the preview images and image resizing functionality -->
        <script src="/core/scripts/blueimp/js/load-image.all.min.js"></script>
        <!-- The Canvas to Blob plugin is included for image resizing functionality -->
        <script src="/core/scripts/blueimp/js/canvas-to-blob.min.js"></script>
        <!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
        <script src="/core/scripts/blueimp/js/jquery.iframe-transport.js"></script>
        <!-- The basic File Upload plugin -->
        <script src="/core/scripts/blueimp/js/jquery.fileupload.js"></script>
        <!-- The File Upload processing plugin -->
        <script src="/core/scripts/blueimp/js/jquery.fileupload-process.js"></script>
        <!-- The File Upload validation plugin -->
        <script src="/core/scripts/blueimp/js/jquery.fileupload-validate.js"></script>
        <!-- The File Upload image preview & resize plugin -->
        <script src="/core/scripts/blueimp/js/jquery.fileupload-image.js"></script>

1 个答案:

答案 0 :(得分:0)

这可能发生在不支持浏览器File API的情况下。你可以使用棘手的方法,如本期,

maxFileSize and acceptFileTypes in blueimp file upload plugin do not work. Why?

上面的回答写了不推荐使用的函数data.originalFiles [0]。而不是使用data.files [data.index]