FileUpload FileUpload1 =(FileUpload)ListView1.InsertItem.FindControl("FileUpload1"); string virtualPath = "~/GigPics/"; string physicalPath = Server.MapPath(virtualPath); string fileName = DateTime.Now.ToString(); string extention = System.IO.Path.GetExtension(FileUpload1.FileName); //存储文件到服务器 FileUpload1.SaveAs(System.IO.Path.Combine(physicalPath, fileName + extention)); //设置虚拟目录的路径 myPicture.ImageUrl = virtualPath + fileName + extention;
时间: 2024-10-12 09:09:18