0
点赞
收藏
分享

微信扫一扫

图片上传的例子

.cs
private int uploadpic()
  {
  
   if(myFile.PostedFile!=null)
   {
    try
    {
     string fileDir="C://Library//PagePic//"; //注此处可更改为你想要上传的目录
     string fileName=System.IO.Path.GetFileName(myFile.PostedFile.FileName);
     string filePath=System.IO.Path.Combine(fileDir,fileName);
     LfikePath.Text=filePath;
     myFile.PostedFile.SaveAs(filePath);
    }
    catch(Exception exc)
    {
     this.AlertBox(exc.Message);
     return -1;
     
      
    }
   }   return 0;
  
  
  
  } 
 
 
 private void BSubmit_Click(object sender, System.EventArgs e)
  {
   
   if(uploadpic()==-1)
   {
   return;
   
   }
    
  }  
 
.aspx
 
 
 <<INPUT id="myFile" type="file" οnchange="document.all.Ifytp.src=this.value" runat="server">> 
<<asp:image id="Ifytp" runat="server" Width="72px">><</asp:image>>

举报

相关推荐

0 条评论