如何在服务器接收文件之前检查文件的大小?
我在上传文件时遇到问题:
为了避免服务器过载,我会在服务器接收之前检查文件的大小强>它。如果我没记错的话,按下包含文件输入字段的表单的提交按钮(),服务器首先会完全接收文件后将检查文件。
I have a issue on uploading files:
In order to avoid an overloading of the server, I would check the size of a file before that the server receives it. If I am not wrong, pressing the submit button of a form which contains a file input field (<input type="file" name="...">
), the server first will entirely receive the file and after will check the file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜测文件上传将有一个 Content-Length 标头,在这种情况下,您可以在服务器端检查它,如果它太大则断开连接。
I'm guessing that file uploads will have a Content-Length header, in which case, you can just check that at the server end and drop the connection if it's too large.