求文件上传的代码,本人新手,对这些都不怎么 了解!!!! 高手们来个文件上传的代码吧,急用啊!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if(btnFile.PostedFile.ContentLength < 1) { Response.Write(Utils.AlertMessage("请选择要上传的文件!")); return; } string strFiltrate = btnFile.PostedFile.FileName; strFiltrate = System.IO.Path.GetExtension(strFiltrate); if(strFiltrate!=".doc" && strFiltrate !=".xls") { Response.Write(Utils.AlertMessage("上传的文件类型只能是WORD或者EXCEL")); return; } //如果该文件夹不存在,则创建 if(System.IO.Directory.Exists(Server.MapPath(FILE_UP_URL))==false) { System.IO.Directory.CreateDirectory(Server.MapPath(FILE_UP_URL)); } string fileType = System.IO.Path.GetExtension(btnFile.PostedFile.FileName); string filePath = btnFile.PostedFile.FileName; //获取文件绝对路径 string oldName = filePath.Substring(filePath.LastIndexOf("\\")+1); //从文件绝对路径字符串中,取到文件名称 int fileSize = btnFile.PostedFile.ContentLength; //取得文件大小 string strxxlsh=Utils.GetRandom(1000,9999); string newName = DateTime.Now.ToString("yyyyMMddHHmmssff") + fileType;/**Insert to table*/ 如何判断多个textBox内容是否为空? 父窗体的ContextMenustrip asp.net 中如何获取表单的内容 如何把WEB的用户控件拿到Form使用? .net中regular expression问题 水晶报表,解决立马放分 程序正常关闭后为何进程中还有该程序,怎么彻底退出应用程序呢? oledb连接access的问题 经理给我一个项目,要求一个月内完成,我觉得最少需要2个月,我该怎么办? 谁能告诉我,这个问题?抱歉,没分了!!! DataSet存放两表的实现同时更新的问题 为什么卸载的时候不执行 Uninstall() 里面的函数呢?郁闷啊
{
Response.Write(Utils.AlertMessage("请选择要上传的文件!"));
return;
}
string strFiltrate = btnFile.PostedFile.FileName;
strFiltrate = System.IO.Path.GetExtension(strFiltrate);
if(strFiltrate!=".doc" && strFiltrate !=".xls")
{
Response.Write(Utils.AlertMessage("上传的文件类型只能是WORD或者EXCEL"));
return;
}
//如果该文件夹不存在,则创建
if(System.IO.Directory.Exists(Server.MapPath(FILE_UP_URL))==false)
{
System.IO.Directory.CreateDirectory(Server.MapPath(FILE_UP_URL));
} string fileType = System.IO.Path.GetExtension(btnFile.PostedFile.FileName);
string filePath = btnFile.PostedFile.FileName; //获取文件绝对路径
string oldName = filePath.Substring(filePath.LastIndexOf("\\")+1); //从文件绝对路径字符串中,取到文件名称
int fileSize = btnFile.PostedFile.ContentLength; //取得文件大小
string strxxlsh=Utils.GetRandom(1000,9999);
string newName = DateTime.Now.ToString("yyyyMMddHHmmssff") + fileType;
/*
*Insert to table
*/