2

尝试使用 Dropzone 上传 3MB 或更大的文件,但它对我不起作用,即使我指定了 500MB 的 maxFilesize。尝试查看其他答案,但它们对我不起作用。

这是我的 HTML:

<form id="dropzone" action="photoupload.php" class="dropzone" enctype="multipart/form-data">
</form><br />

这是我为 Javascript 提供的内容:

Dropzone.options.dropzone = {
    maxFilesize: 500,
    acceptedFiles: "image/*",
    init: function() {
        this.on("uploadprogress", function(file, progress) {
            console.log("File progress", progress);
        });
    }
  }

该脚本适用于接受文件部分(拒绝所有非图像),但不会上传大于 2 到 3 MB 的文件,我不知道为什么。

任何帮助,将不胜感激!

4

2 回答 2

3

Without further information I assume that the problem is related to your server. Obviously Dropzone can not control your server configuration, which often have filesize upload limitations as well.

In your case (PHP) the configuration options in question are upload_max_filesize and post_max_size. Please refer to the question "How to change the maximum upload file size in PHP?" for more information on how to change those options.

于 2013-07-15T17:37:54.150 回答
3

我认为你需要这个:

Dropzone.prototype.accept = function(file, done) {
      if (file.size > this.options.maxFilesize * 1024 * 1024 ) {
        return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
      } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
        return done(this.options.dictInvalidFileType);
      } else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {
        done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
        return this.emit("maxfilesexceeded", file);
      } else {
        return this.options.accept.call(this, file, done);
      }
    };
于 2015-03-20T05:34:13.807 回答