文件上传

        string userid = "qian";
        string FilePath = System.Web.HttpContext.Current.Request.MapPath("memberpic/" + userid+"/");
        if (!Directory.Exists(FilePath))
        {
            Directory.CreateDirectory(FilePath);
        }
        string photoName1 = FileUpload1.PostedFile.FileName; //获取初始文件名
        int i = photoName1.LastIndexOf("."); //取得文件名中最后一个"."的索引
        string newext = photoName1.Substring(i); //获取文件扩展名
        //重新为文件命名,获取时间的年月日时分秒部分
        FileUpload1.PostedFile.SaveAs(Server.MapPath("memberpic/" + userid+"/" + userid + newext));

 

posted @ 2012-09-05 15:39  帅的纯净水  阅读(55)  评论(0)    收藏  举报