FileUpload控件
来源:互联网 发布:人工智能电影 编辑:程序博客网 时间:2024/05/22 11:58
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class FileUpload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
bool fileOK = false;
string path = Server.MapPath("~/temp/");
if (FileUpload1.HasFile)
{
String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
String[] allowedExtension ={ ".gif", ".png", ".bmp", ".jpg" };
for (int i = 0; i < allowedExtension.Length; i++)
{
if (fileExtension == allowedExtension[i])
{ fileOK = true; }
}
}
if (fileOK)
{
try
{
FileUpload1.SaveAs(path + FileUpload1.FileName);
Label1.Text = "文件上传成功!";
}
catch (Exception ex)
{ Label1.Text = "文件上传不成功!"; }
}
else
{ Label1.Text = "只能上传图片文件!"; }
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class FileUpload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
bool fileOK = false;
string path = Server.MapPath("~/temp/");
if (FileUpload1.HasFile)
{
String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
String[] allowedExtension ={ ".gif", ".png", ".bmp", ".jpg" };
for (int i = 0; i < allowedExtension.Length; i++)
{
if (fileExtension == allowedExtension[i])
{ fileOK = true; }
}
}
if (fileOK)
{
try
{
FileUpload1.SaveAs(path + FileUpload1.FileName);
Label1.Text = "文件上传成功!";
}
catch (Exception ex)
{ Label1.Text = "文件上传不成功!"; }
}
else
{ Label1.Text = "只能上传图片文件!"; }
}
}
- FileUpLoad控件
- FileUpload控件
- FileUpload控件
- FileUpLoad控件
- FileUpload控件
- fileupload控件
- fileupload控件
- FileUpload控件
- FileUpload控件
- FileUpload控件
- FileUpload控件
- FileUpload控件
- FileUpload控件
- FileUpload 服务器控件示例
- 标签与控件fileupload
- 上传控件---FileUpload
- 文件上传控件(FileUpload)
- FileUpload控件预览图片
- 嵌入式产品UI设计注意事项
- asp常用函数速查表
- 表现层框架Struts/Tapestry/JSF架构比较
- Flash脚本语言as学习扎记-摘自某小学网站
- 新来乍到
- FileUpload控件
- Using VirtualBox to run Ubuntu and any other operating system
- JavaScript:世界上最被误解的语言
- 国际户外运动品牌简介
- Berkeley DB(BDB)介绍
- Get与Post的区别
- crosstab reports
- IE6下Ms Ajax Lib 调用Ajaxtoolkit时Common_InvalidPaddingUnit未定义的解决方法
- Visual Studio Object Model中每个Project对象的所有Property 索引项