FileUpload控件的使用
string name = this.FileUpload1.FileName;
string size = FileUpload1.PostedFile.ContentLength.ToString();
string type = FileUpload1.PostedFile.ContentType;
string type2 = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("upimg") + "\\" + name;
string fpath = Server.MapPath("upfile") + "\\" + name;
string wpath = "upimg\\" + name;
if (type2 == "jpg" || type2 == "gif" || type2 == "bmp" || type2 == "png")
{
FileUpload1.SaveAs(ipath);
Image1.ImageUrl = wpath;
Label1.Text = "Your load file is " + name + "<br>size is:" + size + "byte<br>file style is:" + type + "<br>ext name is :" + type2 + "<br>fac path is :" + ipath + "<br> vir path is:" + wpath;
}
else
{
Image1.Visible = false;
FileUpload1.SaveAs(fpath);
Label1.Text = "Your load file is " + name + "<br>size is:" + size + "byte<br>file style is:" + type + "<br>ext name is :" + type2 + "<br>fac path is :" + ipath + "<br> vir path is:" + wpath;
}
string size = FileUpload1.PostedFile.ContentLength.ToString();
string type = FileUpload1.PostedFile.ContentType;
string type2 = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("upimg") + "\\" + name;
string fpath = Server.MapPath("upfile") + "\\" + name;
string wpath = "upimg\\" + name;
if (type2 == "jpg" || type2 == "gif" || type2 == "bmp" || type2 == "png")
{
FileUpload1.SaveAs(ipath);
Image1.ImageUrl = wpath;
Label1.Text = "Your load file is " + name + "<br>size is:" + size + "byte<br>file style is:" + type + "<br>ext name is :" + type2 + "<br>fac path is :" + ipath + "<br> vir path is:" + wpath;
}
else
{
Image1.Visible = false;
FileUpload1.SaveAs(fpath);
Label1.Text = "Your load file is " + name + "<br>size is:" + size + "byte<br>file style is:" + type + "<br>ext name is :" + type2 + "<br>fac path is :" + ipath + "<br> vir path is:" + wpath;
}
浙公网安备 33010602011771号