[英]Data upload size limit to API
Suppose I want to upload a CSV file
using javascript and send that file to my REST API.
假设我想使用 javascript 上传一个
CSV file
并将该文件发送到我的REST API.
What can be the maximum size of the file that I can upload which can be handled by my API
? handled by my API
可以handled by my API
上传文件的最大大小是多少?
I searched and somewhat got to know that file size cannot exceed 10Mb.
我搜索了一下,知道文件大小不能超过
10Mb.
Please correct me if I am wrong.如果我错了,请纠正我。
you can located the input
tag using document.querySelector
or using jQuery $()
and in that tag there is a nested property called size
( input.files[0].size
) this property return the size of you file in a byte.您可以使用
document.querySelector
或使用jQuery $()
定位input
标签,并且在该标签中有一个名为size
( input.files[0].size
) 的嵌套属性,此属性以字节为单位返回文件的大小。 from there all you need to is bind to the onchange
event of the input
, check the file size and if it's over 10MB alert a message and clear the input从那里你只需要绑定到
input
的onchange
事件,检查文件大小,如果超过10MB提醒消息并清除输入
document.querySelector('[type="file"]').addEventListener('change',function(e){ if(e.target.files[0].size > 10000000){ alert('file size greater then 10MB'); e.target.value = null } })
<input type="file"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.