C#中文件上传代码
FileUpload FileUpload1 =(FileUpload)ListView1.InsertItem.FindControl("FileUpload1"); string virtualPath = "~/GigPics/"; string physicalPath = Server.MapPath(virtualPath); string fileName =DateTime.Now.ToString("yyyyMMddhhmmss");//获取当前时间 年月日时分秒 大写的MM是月,小写的mm是分钟
string extention = System.IO.Path.GetExtension(FileUpload1.FileName); //存储文件到服务器
FileUpload1.SaveAs(System.IO.Path.Combine(physicalPath, fileName + extention)); //设置虚拟目录的路径
myPicture.ImageUrl = virtualPath + fileName + extention;