Which js library can I use to upload files from any browser and will allow client-side restriction of the file size

有帮助吗?

解决方案 2

Try jquery File Uploader

it has option

maxFileSize

The maximum allowed file size in bytes.

Type: integer Default: undefined Example: 10000000 // 10 MB Note: This option has only an effect for browsers supporting the File API.

But old browsers don't support this feature. And unlikely there are any way to fix it

其他提示

dropzone.js can. dropzone website their example:

Dropzone.options.myAwesomeDropzone = {
  paramName: "file", // The name that will be used to transfer the file
  maxFilesize: 2, // MB
  accept: function(file, done) {
    if (file.name == "justinbieber.jpg") {
      done("Naha, you don't.");
    }
    else { done(); }
  }
};

Try https://github.com/mailru/FileAPI We using this library in our web projects, works fine in any browsers except android default browser.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top