`
thecloud
  • 浏览: 882473 次
文章分类
社区版块
存档分类
最新评论

图片上传的例子

 
阅读更多

.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" onchange="document.all.Ifytp.src=this.value" runat="server">>
<<asp:image id="Ifytp" runat="server" Width="72px">><</asp:image>>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics