问题描述
HttpFileCollectionfiles=HttpContext.Current.Request.Files;inti,err;//ID=0;err=0;stringfileName,fileExtension,SaleExtension,message;//url="";message="";SaleExtension="|.jpg|,|.gif|,|.png|";//try{//检验上传的所有图片if(files.Count>0){for(i=0;i<files.Count;i++){HttpPostedFilefile=files[i];fileName=System.IO.Path.GetFileName(file.FileName);fileExtension=System.IO.Path.GetExtension(file.FileName).ToLower();if(file.ContentLength>(500*1024)){err=1;message+="<b>"+file.FileName+"</b>图片太大,请选择小一点的图片上传!<br>";}if(file.ContentLength<1){err=8;message+="<b>"+file.FileName+"</b>图片错误,请确定选择的是正确的文件路径!<br>";}if(SaleExtension.IndexOf("|"+fileExtension+"|")<0){err=2;message+="<b>"+file.FileName+"</b>文件类型不正确,只能上传(.gif,.jpg,.png)类型的图片文件!<br>";}}}else{err=7;//未上传图片message+="未上传图片<br>";}}//catch{//err=100;}
解决方案
解决方案二:
form中加了个enctype="multipart/form-data"也不行,请高手帮忙
解决方案三:
到baidu搜一把多文件上传里面有具体的还的等我了解了在给你说我才一X
解决方案四:
<%@Pagelanguage="c#"Codebehind="UpLoadPic.aspx.cs"AutoEventWireup="true"Inherits="qinqin.admin.Baike.UpLoadPic"%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><HTML><HEAD><title>图片上传</title><metacontent="MicrosoftVisualStudio.NET7.1"name="GENERATOR"><metacontent="C#"name="CODE_LANGUAGE"><metacontent="JavaScript"name="vs_defaultClientScript"><metacontent="http://schemas.microsoft.com/intellisense/ie5"name="vs_targetSchema"><scriptlanguage="javascript"src="../File.js"type="text/javascript"></script><LINKhref="../style.css"type="text/css"rel="stylesheet"></HEAD><body><formid="Form1"method="post"encType="multipart/form-data"runat="server"><TABLEcellSpacing="0"cellPadding="0"width="750"align="center"border="0"><TBODY><TR><TDvAlign="middle"align="center"width="146"background="../images/admin_product_09.jpg"height="31">上传新闻图片<TDwidth="600"> </TD></TR><TR><TDalign="center"colSpan="2"><TABLEborderColor="#d2f0ff"cellSpacing="0"cellPadding="0"width="100%"align="center"border="1"><tr><tdalign="center"><TABLEid="Table1"cellSpacing="0"cellPadding="0"width="500"align="center"border="0"><TR><TDheight="20">图片可以直接拖曳到编辑器中使用 <Ahref="UpLoadPic_Manage.aspx"target="_blank">历史上传图片</A><BR><asp:labelid="Message"runat="server"ForeColor="Red"></asp:label></TD></TR><TR><TDvAlign="top"height="50"><asp:labelid="Images"runat="server"></asp:label></TD></TR><TR><TDheight="30"><INPUTid="pic"type="file"name="pic"><INPUTonclick="AddFile('myfile')"type="button"value="增加图片"><BR><SPANid="myfile"></SPAN></TD></TR><tr><tdcolSpan="2"><asp:buttonid="Submit"onclick="Submit_Click"runat="server"Text="提交"></asp:button></td></tr></TABLE></td></tr></TABLE></TD></TR></TBODY></TABLE></form></body></HTML>htm代码