简体   繁体   English

我可以使用哪个客户端js库上传文件,可以限制文件大小

[英]which client side js library can I use for file upload where file size can be restricted

我可以使用哪个js库从任何浏览器上传文件,并允许客户端限制文件大小

dropzone.js can. dropzone.js可以。 dropzone website their example: dropzone网站的示例:

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 jquery File Uploader 试用jquery文件上传器

it has option 它有选择

maxFileSize 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. 类型:整数默认值:undefined示例:10000000 // 10 MB注意:此选项仅对支持File API的浏览器有效。

But old browsers don't support this feature. 但是旧的浏览器不支持此功能。 And unlikely there are any way to fix it 而且不太可能有任何方法来解决它

尝试https://github.com/mailru/FileAPI我们在我们的Web项目中使用该库,在除android默认浏览器以外的任何浏览器中均可正常运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用SPServices使用dropzone.js将文件上传到SharePoint文件库? - How can I use dropzone.js to upload files to a SharePoint file Library using SPServices? 我如何使用这个由 vanila js 制作的自定义文件上传按钮到 React 应用程序中? - How can I use this custom file upload button which is made by vanila js into React application? 如何调用客户端库的特定js文件? - How can I call specific js file of a client library? 如何在客户端 javascript 中使用 node.js 缓冲区库 - How can I use node.js buffer library in client side javascript 我可以在 electron.js 中预加载完整的 javascript 库并在客户端使用它吗? - Can I preload a full javascript library in electron.js and use it on the client side? 如何使用ActionScript和JavaScript在客户端获取文件大小? - how can I get file size at client side using actionscript and javascript? 如何使用另一个.js文件中的函数? - How can I use a function which is into another .js file? 如何从客户端获取 CSV 文件上传请求并解析要上传到 nodejs 中的 mySql 数据库中的数据 - how can i get a CSV file upload request from client side and parse the data to upload in mySql database in nodejs 我怎么知道 php 文件是否仅从客户端的 js 调用? - how can i know if a php file was only called from js on the client side? 在IE中上传文件之前,如何获取文件大小? - How can I get a file size before upload file in IE?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM