//var fileName = System.IO.Path.GetFileName(upload.FileName);
//var filePhysicalPath = Server.MapPath("~/Content/" + fileName);//我把它保存在网站根目录的 upload 文件夹
var fileName = Path.Combine(Request.MapPath("~/Content"),
Path.GetFileName(upload.FileName));
upload.SaveAs(fileName);
var url = "/Content/" + upload.FileName;
var CKEditorFuncNum = System.Web.HttpContext.Current.Request["CKEditorFuncNum"];
//上传成功后,我们还需要通过以下的一个脚本把图片返回到第一个tab选项
return Content("<script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\");</script>");
string fileExt = postFile.FileName.Substring(postFile.FileName.LastIndexOf(".") + 1); //文件扩展名,不含“.”
string newFileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + "." + fileExt; //随机生成新的文件名
string upLoadPath = "~/Picture/"; //上传目录相对路径
string fullUpLoadPath = Server.MapPath(upLoadPath); //将路径转换成 物理路径
string newFilePath = upLoadPath + newFileName; //上传后的路径
postFile.SaveAs(fullUpLoadPath + newFileName); //核心方法
return Json(new { success=true, message="", remark= "/Picture/" + newFileName });