上传大文件时出错,急,全部分相送

lwbst 2005-12-15 09:38:18
我要实现的功能;我在点net里上传大文件时,当上传到5M时,我要求有提示,
我现在的问题:我在上传时用if(this.File1.PostedFile.InputStream.Length>1024*1024*5)这个来限制大小,但是在上传大文件时还是会先去读入全部的文件,再检查大小,晕死了,我本来是想不全部读入文件,就可以检查大小.


有没办法不读入全部的文件,就能知道它的大小,用INPUT type="file" id="File1" name="File1" runat=server size="28"来实现的,

在点net里有没有办法呢
...全文
79 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zbyh331 2005-12-15
  • 打赏
  • 举报
回复
这样不用啊,在WEB。CONFIG里添加设置代码:
<configuration>
<system.web>
<httpruntime
maxrequestlength="4096"//此大小为默认值,此值可以根据需要改变
executiontimeout="600"//此值指定上传文件有效时间为10分钟
/>
</system.web>
</configuration>

修改machine.config
httpRuntime Attributes:
//修改时间 executionTimeout="[seconds]" - time in seconds before request is automatically timed out
//修改大小 maxRequestLength="[KBytes]" - KBytes size of maximum request length to accept
useFullyQualifiedRedirectUrl="[true|false]" - Fully qualifiy the URL for client redirects
minFreeThreads="[count]" - minimum number of free thread to allow execution of new requests
minLocalRequestFreeThreads="[count]" - minimum number of free thread to allow execution of new local requests
appRequestQueueLimit="[count]" - maximum number of requests queued for the application
enableKernelOutputCache="[true|false]" - enable the http.sys cache on IIS6 and higher - default is true
enableVersionHeader="[true|false]" - outputs X-AspNet-Version header with each request

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧