后台Action:
[HttpPost]
public string UploadFile()
{
if (Request.Form.Files.Count == 0)
return GetFalseResult("未检测到文件");
string path = hostingEnv.ContentRootPath + "\\wwwroot\\Files";
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
var file = Request.Form.Files[0];
string fileExt = file.FileName.Split('.')[file.FileName.Split('.').Length - 1];
string filename = Guid.NewGuid().ToString() + "." + fileExt;
string fileFullName = path + "\\" + filename;
using (FileStream fs = System.IO.File.Create(fileFullName))
{
file.CopyTo(fs);
fs.Flush();