`

最简单的上传文件

 
阅读更多

public string GetSqlFile(string dir)
{
string sqlfile ="";
HttpFileCollection files = HttpContext.Current.Request.Files;
if(files.Count>0)
{
try
{
string fileName = files[0].FileName;
string filetype = fileName.Substring(fileName.LastIndexOf("."));
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
//string path = Server.MapPath("../proimg"+"\\"+date+filetype);
sqlfile = date+filetype;
files[0].SaveAs(dir+"\\"+sqlfile);

}
catch(Exception ex)
{
HttpContext.Current.Response.Write(AlertM.Alert(ex.Message));
return "";
}


}
return sqlfile;



}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics