测试时,上传组件传图片。代码如下,但传不上去 测试PostedFile = null
我用好几个上传代码,最后都穿不上去,就是 postefile =null
到底有没有高手能解决啊,。。!!!!!
<asp:Panel ID="MyPanel2" runat="server" >
<tr>
<td>
上传照片:</td>
<td colspan="3" s="">
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="button1" runat="server" Text="上 传" CssClass="BnCss" OnClick="button2_Click" />
<asp:Label ID="Label6" runat="server"></asp:Label></td>
</tr>
</asp:Panel>
============================================================================
protected void button2_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.ContentLength == 0)
{
src = "";
}
else
{
string zname = this.B_TITLE.Text.Trim();
string strFilePath = FileUpload1.PostedFile.FileName;
FileInfo fl = new FileInfo(strFilePath);
string Ext = fl.Extension;
if (Ext.Equals(".jpg") || Ext.Equals(".gif") || Ext.Equals(".png") || Ext.Equals(".ico"))
{
src = zname + Ext;
string ServerPath = Server.MapPath("~");
string strSeraPath = ServerPath + "\\picture\\" + src;
FileUpload1.PostedFile.SaveAs(strSeraPath);
this.Label1.Text = "图片上传成功";
src = zname + Ext;