這些天都在做一個貿易的程序,有些方法和技巧要記下來,以防將來忘記!今天先把文件上傳的方法記下來
string Path;
string FileName;
int Po;
long FileSize;
string fType;
if(F.PostedFile.FileName.Trim() != "")
{
try
{
Path=Server.MapPath("images").ToString();
FileName=F.PostedFile.FileName.ToString();
fType=F.PostedFile.ContentType;
FileSize=F.PostedFile.ContentLength;
if(fType.Substring(0,5)!="image")
{
Response.Write("PostFile is not Image!");
return;
}
Po=FileName.LastIndexOf((char)92);
FileName=FileName.Substring(Po+1,FileName.Length -Po-1);
ViewState["PostFileName"]=FileName;
F.PostedFile.SaveAs(Path+");
this.imgBookCover.Visible =true;
this.imgBookCover.ImageUrl= "images/"+FileName;
}
catch
{
}
finally
{
}
}
阅读(771) | 评论(0) | 转发(0) |