我試圖重新創建MVC3中的WordPress圖像上傳功能,其中彈出允許您插入圖像url和編輯圖像屬性,如alt標籤,大小和位置在它被上傳到服務器之後。我嘗試過使用jqueryUi和一個上傳的ActionResult,並且能夠上傳文件,但是現在我試圖將上傳的URL返回到彈出窗口。幫助重新創建Wordpress圖像上傳與ASP MVC3
任何人都試過併成功與此?
編輯:
這裏是我的ActionResult是上傳並準備上傳的圖片的URL。
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Content/Uploads"), fileName);
file.SaveAs(path);
//Below is the path I want returned to mypop-up
ViewBag.WebPath = "/Content/Uploads/" + fileName;
}
//no idea which Return string to use...
}
我jQueryUI的對話框:
$('#upload-dialog').dialog({
autoOpen: false,
width: 600,
resizable: false,
title: 'Upload Image',
modal: true,
open: function (event, ui) {
$(this).load('@Url.Action("UploadImagePartial")');
},
buttons: {
"Close": function() {
$(this).dialog("close");
}
}
});
任何使用有想法json或ajax? – Ron