//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 });