⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_34488.htm

📁 vc
💻 HTM
字号:
<p>
序号:34488 发表者:kittyfish 发表日期:2003-03-30 18:56:08
<br>主题:[求助]文件上传的aspx怎么超过4M就不能传了?
<br>内容:求助。<BR>但是代码里面也没有什么限制的地方呀。<BR>搞了很久也没想通。<BR>真是郁闷。<BR>希望有高手指点,小弟不胜感激!
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:kittyfish 回复日期:2003-03-30 18:58:40
<br>内容:我是用的HttpInputFile控件<BR>以及saveas语句.<BR>只能上传4M以下的。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:beiqiao 回复日期:2003-03-31 19:57:47
<br>内容:能否贴出代码
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:kittyfish 回复日期:2003-04-01 21:33:19
<br>内容:主要代码是:<BR> public void UploadFile(object sender , EventArgs E) <BR>{<BR>if(myFile.PostedFile!=null) <BR>{<BR>string nam=myFile.PostedFile.FileName ;<BR>int i= nam.LastIndexOf("\\") ; <BR>string newnm =nam.Substring(i) ; <BR>myFile.PostedFile.SaveAs("F:\\Upload\\"+newnm) ; <BR>//取得上传文件的各种属性。 <BR>fname.Text=myFile.PostedFile.FileName; <BR>fenc.Text=myFile.PostedFile.ContentType; <BR>fsize.Text=(myFile.PostedFile.ContentLength/1024).ToString(); <BR>}<BR>}<BR><BR>不知道为什么文件大于4M,就有问题。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:beiqiao 回复日期:2003-04-02 21:59:31
<br>内容:我试了试,的确如此<BR><BR>个人感觉是iis+asp.net的问题,asp.net的嫌疑更大些,可能是配置问题,也可能是微软自身的bug。<BR><BR>今天没有时间查了,抓紧最后一点时间cs一把,kittyfish兄弟如果已经解决了这个问题,也告诉我吧,谢谢
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:落叶夏日 回复日期:2003-04-03 12:36:15
<br>内容:我也在关注中,有了告诉我 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:兰兰的天空 回复日期:2003-04-05 18:19:06
<br>内容:不是吧,兄弟们。<BR>竟然是这样呀.............<BR>郁闷啦..........<BR>还有,怎么那么多人被接受为正确答案呀。<BR><BR>是不是要改用其他上传方式呀。<BR>比如说,用流(Stream);<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:落叶夏日 回复日期:2003-04-07 19:14:34
<br>内容:对,可以用其它方法,不过我也在关注这个,太大好象不可以
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:beiqiao 回复日期:2003-04-07 19:31:31
<br>内容:用HttpRequest.BinaryRead方法应该是可以地,下面是用上传文件的C处理方法,仅供参考<BR><BR><BR><BR>int FileSave(char *sFileName)<BR>{<BR>&nbsp;&nbsp;int&nbsp;&nbsp;amount;<BR>&nbsp;&nbsp;int&nbsp;&nbsp;loop;<BR>&nbsp;&nbsp;int&nbsp;&nbsp;cnt;<BR><BR>&nbsp;&nbsp;char *name, *value, *filename, *contenttype;<BR>&nbsp;&nbsp;int&nbsp;&nbsp;valuelen;<BR><BR>&nbsp;&nbsp;char boundary[256], boundaryEOF[256];<BR>&nbsp;&nbsp;char rnboundaryrn[256], rnboundaryEOF[256];<BR>&nbsp;&nbsp;int&nbsp;&nbsp;boundarylen, boundaryEOFlen, maxboundarylen;<BR><BR>&nbsp;&nbsp;char buf[1024];<BR>&nbsp;&nbsp;int&nbsp;&nbsp;i,c, c_count;<BR>&nbsp;&nbsp;int finish;<BR>&nbsp;&nbsp;FILE * fi;<BR>&nbsp;&nbsp;<BR><BR>&nbsp;&nbsp;if(sFileName == NULL || strlen(sFileName) ==0)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;if((fi = fopen(sFileName, "wb"))==NULL){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;<BR>&nbsp;&nbsp;};<BR>&nbsp;&nbsp;/* For parse multipart/form-data method */<BR>&nbsp;&nbsp;/* Force to check the boundary string length to defense overflow attack */<BR>&nbsp;&nbsp;maxboundarylen =&nbsp;&nbsp;strlen("--");<BR>&nbsp;&nbsp;maxboundarylen += strlen(strstr(getenv("CONTENT_TYPE"), "boundary=") + strlen("boundary="));<BR>&nbsp;&nbsp;maxboundarylen += strlen("--");<BR>&nbsp;&nbsp;maxboundarylen += strlen("\r\n");<BR>&nbsp;&nbsp;if(maxboundarylen &gt;= sizeof(boundary)) printf("_parse_multipart_data(): The boundary string is too long. Stopping process.");<BR><BR>&nbsp;&nbsp;/* find boundary string */<BR>&nbsp;&nbsp;sprintf(boundary,&nbsp;&nbsp;&nbsp;&nbsp;"--%s", strstr(getenv("CONTENT_TYPE"), "boundary=") + strlen("boundary="));<BR>&nbsp;&nbsp;/* This is not necessary but, I can not trust MS Explore */<BR>&nbsp;&nbsp;qRemoveSpace(boundary);<BR><BR>&nbsp;&nbsp;sprintf(boundaryEOF, "%s--", boundary);<BR><BR>&nbsp;&nbsp;sprintf(rnboundaryrn, "\r\n%s\r\n", boundary);<BR>&nbsp;&nbsp;sprintf(rnboundaryEOF, "\r\n%s", boundaryEOF);<BR><BR>&nbsp;&nbsp;boundarylen&nbsp;&nbsp;&nbsp;&nbsp;= strlen(boundary);<BR>&nbsp;&nbsp;boundaryEOFlen = strlen(boundaryEOF);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;/* check boundary */<BR> <BR>&nbsp;&nbsp;if(_fgets(buf, sizeof(buf), stdin) == NULL) printf("_parse_multipart_data(): Your browser sent a non-HTTP compliant message.");<BR><BR>&nbsp;&nbsp;/* for explore 4.0 of NT, it sent \r\n before starting, f u cking Micro$oft */<BR>&nbsp;&nbsp;if(!strcmp(buf, "\r\n")) _fgets(buf, sizeof(buf), stdin);<BR><BR>&nbsp;&nbsp;if(strncmp(buf, boundary, boundarylen) != 0) printf("_parse_multipart_data(): String format invalid.");<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;for(finish = 0, cnt = 0; finish != 1; amount++, cnt++) {<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;/* parse header */<BR>&nbsp;&nbsp;&nbsp;&nbsp;name = "";<BR>&nbsp;&nbsp;&nbsp;&nbsp;filename = "";<BR>&nbsp;&nbsp;&nbsp;&nbsp;contenttype = "";<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;while(_fgets(buf, sizeof(buf), stdin)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!strcmp(buf, "\r\n")) break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if(!qStrincmp(buf, "Content-Disposition: ", strlen("Content-Disposition: "))) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* get name field */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name = strdup(buf + strlen("Content-Disposition: form-data; name=\""));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(c_count = 0; (name[c_count] != '\"') &amp;&amp; (name[c_count] != '\0'); c_count++);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name[c_count] = '\0';<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* get filename field */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(strstr(buf, "; filename=\"") != NULL) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int erase;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filename = strdup(strstr(buf, "; filename=\"") + strlen("; filename=\""));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(c_count = 0; (filename[c_count] != '\"') &amp;&amp; (filename[c_count] != '\0'); c_count++);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filename[c_count] = '\0';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* erase '\' */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(erase = 0, c_count = strlen(filename) - 1; c_count &gt;= 0; c_count--) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(erase == 1) filename[c_count]= ' ';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(filename[c_count] == '\\') {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;erase = 1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filename[c_count] = ' ';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;qRemoveSpace(filename);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if(!qStrincmp(buf, "Content-Type: ", strlen("Content-Type: "))) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contenttype = strdup(buf + strlen("Content-Type: "));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;qRemoveSpace(contenttype);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;/* get value field */<BR>&nbsp;&nbsp;&nbsp;&nbsp;for(value = NULL, valuelen = (1024 * 16), c_count = 0; (c = fgetc(stdin)) != EOF; ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(c_count == 0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value = (char *)malloc(sizeof(char) * valuelen);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(value == NULL) printf("_parse_multipart_data(): Memory allocation fail.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if(c_count == valuelen - 1) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char *valuetmp;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;valuelen *= 2;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Here, we do not use realloc(). Because sometimes it is unstable. */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;valuetmp = (char *)malloc(sizeof(char) * valuelen);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(valuetmp == NULL) printf("_parse_multipart_data(): Memory allocation fail.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memcpy(valuetmp, value, c_count);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free(value);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value = valuetmp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value[c_count++] = (char)c;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* check end */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if((c == '\n') || (c == '-')) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value[c_count] = '\0';<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if((c_count - (2 + boundarylen + 2)) &gt;= 0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!strcmp(value + (c_count - (2 + boundarylen + 2)), rnboundaryrn)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value[c_count - (2 + boundarylen + 2)] = '\0';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;valuelen = c_count - (2 + boundarylen + 2);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if((c_count - (2 + boundaryEOFlen)) &gt;= 0) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!strcmp(value + (c_count - (2 + boundaryEOFlen)), rnboundaryEOF)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp; if(strcmp(filename, "") != 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i = 0; i &lt; valuelen; i++) fputc(*value++, fi); <BR>&nbsp;&nbsp;}<BR>fclose(fi);<BR>return 1;<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:落叶夏日 回复日期:2003-04-09 12:42:54
<br>内容:我找到答案了,不过不是我发现的,呵呵<BR>这是默认传输的最大数据量<BR>你在web.config里写入这些,其中maxRequestLength的值就是你要传的最大值<BR>&lt;configuration&gt;<BR>&lt;system.web&gt;<BR>&lt;httpRuntime maxRequestLength="614400"/&gt;<BR>&lt;/system.web&gt;<BR>&lt;/configuration&gt;<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:beiqiao 回复日期:2003-04-09 19:34:55
<br>内容:i see
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:兰兰的天空 回复日期:2003-04-15 17:59:21
<br>内容:非常感谢。<BR>我试一下。<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -