日期:2014-05-17 浏览次数:20762 次
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Boolean fileOK = false;
String path = Server.MapPath("192.168.0.222/root/");
if (file1.HasFile)
{
String fileExtension =
System.IO.Path.GetExtension(file1.FileName).ToLower();
String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
}
}
}
if (fileOK)
{
try
{
file1.PostedFile.SaveAs(path
+ file1.FileName);
lbcg.Text = "File uploaded!";
}
catch (Exception ex)
{
lbcg.Text = "文件无法上传.";
}
}
&