using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMAPP.Common.Web.Controllers;
using System.Text;
namespace QMAPP.FJC.Web.Controllers
{
public class FileController : QController
{
#region 上传文件
///
/// 载入行为
///
///
public ActionResult UploadFile()
{
return View();
}
///
/// 上传行为
///
/// 文件
/// js
[HttpPost]
public ActionResult UploadFile(HttpPostedFileBase file)
{
string expandName = "";
string fileName = file.FileName;
try
{
//构造文件名
if (fileName.IndexOf(".") > 0)
{
expandName = fileName.Substring(fileName.LastIndexOf(".") + 1);
}
fileName = Guid.NewGuid().ToString() + "." + expandName;
//保存文件
file.SaveAs(MvcApplication.TempPath + fileName);
return this.GetJsViewResult(string.Format("window.returnValue='{0}';window.close();", System.Web.HttpUtility.UrlEncode(fileName, Encoding.UTF8)));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}