.net 接受上传文件的代码
if (Request.Files.Count != 0) { HttpPostedFile MyUpFile = Request.Files["file"]; if (!string.IsNullOrEmpty(MyUpFile.FileName)) { string fileName=Path.GetFileName(MyUpFile.FileName); filePath = ConfigurationManager.AppSettings["AttPath"] + "/Accessories/"; filePath = filePath + project.ProjectID + "/"; string folder = Function.CreateRandomDirectoryFolder(filePath) + "/"; filePath = filePath + folder; filePath = filePath + fileName; MyUpFile.SaveAs(filePath); url = ConfigurationManager.AppSettings["AttUrl"]; url += "/Accessories/" + project.ProjectID + "/" + folder + fileName; } }