FileUpload上传文件的基本步骤

1.string filepath=FileUpload1.PostedFile.FileName;//获取上传文件的路径

2.string filename=filepath.Substring(filepath.LastIndexOf("\\")+1);//获取上传文件名称

3.string fileExtend=filepath.Substring(filepath.LastIndexOf(".")+1);//获取文件的扩展名

4.string fileSize=Convert.ToString(FileUpload1.PostedFile.ContenLength);//获取文件大小

5.string fileType=FileUpload1.PostecFile.ContentType;//获取文件类型

6.string serverPath=Server.MapPath("指定文件夹下")+filename;//保存到服务器的路径

7.FileUpload1.SavaAs(serverPath);//确定上传文件

posted @ 2014-04-08 15:15  雨中超越  阅读(1215)  评论(1编辑  收藏  举报