请教高手为什么我的files.count得到的都是0呢
HttpFileCollection files=HttpContext.Current.Request.Files;int i,err;
// ID=0;
err=0;
string fileName,fileExtension,SaleExtension,message;
// url="";
message="";
SaleExtension="|.jpg|,|.gif|,|.png|";
//try
{
//检验上传的所有图片
if(files.Count>0)
{
for(i=0;i<files.Count;i++)
{
HttpPostedFile file=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 --------------------编程问答-------------------- <%@ Page language="c#" Codebehind="UpLoadPic.aspx.cs" AutoEventWireup="true" Inherits="qinqin.admin.Baike.UpLoadPic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>图片上传</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript" src="../File.js" type="text/javascript"></script>
<LINK href="../style.css" type="text/css" rel="stylesheet">
</HEAD>
<body>
<form id="Form1" method="post" encType="multipart/form-data" runat="server">
<TABLE cellSpacing="0" cellPadding="0" width="750" align="center" border="0">
<TBODY>
<TR>
<TD vAlign="middle" align="center" width="146" background="../images/admin_product_09.jpg"
height="31">
上传新闻图片
<TD width="600"> </TD>
</TR>
<TR>
<TD align="center" colSpan="2">
<TABLE borderColor="#d2f0ff" cellSpacing="0" cellPadding="0" width="100%" align="center"
border="1">
<tr>
<td align="center">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="500" align="center" border="0">
<TR>
<TD height="20">图片可以直接拖曳到编辑器中使用 <A href="UpLoadPic_Manage.aspx" target="_blank">历史上传图片</A><BR>
<asp:label id="Message" runat="server" ForeColor="Red"></asp:label></TD>
</TR>
<TR>
<TD vAlign="top" height="50"><asp:label id="Images" runat="server"></asp:label></TD>
</TR>
<TR>
<TD height="30"><INPUT id="pic" type="file" name="pic"><INPUT onclick="AddFile('myfile')" type="button" value="增加图片"><BR>
<SPAN id="myfile"></SPAN>
</TD>
</TR>
<tr>
<td colSpan="2"><asp:button id="Submit" onclick="Submit_Click" runat="server" Text="提交"></asp:button></td>
</tr>
</TABLE>
</td>
</tr>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</form>
</body>
</HTML>
htm代码
补充:.NET技术 , ASP.NET