ASP FileUpload 文件大小问题
我在我的 asp 应用程序中使用文件上传控件,当文件上传大小大于最大请求长度时,它会抛出 HttpException。
据我了解,一旦文件浏览对话框关闭,文件上传将打开文件的内存流,但无法知道对话框何时关闭,以便我可以决定是否中止上传。
有谁知道在上传开始之前检查文件大小的方法?
垃圾邮件。
Im using a fileupload control for my asp application and it throws a HttpException when the file upload size is bigger than the max request length.
As far i understand the fileupload will open a memory stream to a file once the file browse dialog is closed but there is no way of knowing when the dialog is closed so that I can make a decision whether to abort the upload.
Does anyone know of a way of examining the file size before the upload begins?
Spam.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果将文件上传留给内置的 Asp.Net 机制,那么如果请求大小大于 web.config(或 machine.config)中设置的最大大小,上传将会失败。
您可以通过编写自己的 HttpHandler 并首先检查请求的大小,然后在代码中处理请求数据来解决这个问题。
If you leave file upload to built-in Asp.Net mechanisms, then an upload will fail if the request size is larger than the max size set in web.config (or machine.config).
You can solve that by writing your own HttpHandler and first check the size of the request, and then handle the request data in your code.
该控件允许您上传任何大小的文件。 我用它,它非常非常方便。 我相信如果你想要的话,来源就在那里。
http://www.brettle.com/neatupload
This control will let you upload any file size. I use it and it is very very handy. I believe the source is there if you want it.
http://www.brettle.com/neatupload
我怀疑是否有一种通用的方法来检查客户端的文件大小(我的意思是对于所有浏览器),因为通常客户端脚本无法访问文件系统。
我曾经在使用经典 ASP 编程时捕获服务器端的异常,然后通知用户。
I doubt there is a universal way to check file size on client-side ( I mean for all browsers ), as usually client-side script does not have access to file system.
I used to catch the exception on server side and then notice the user when programming in classic ASP.