我正在使用 Imageresizer 并上传照片。我想获取我收到的 URL 并将其返回到我的视图。我有我想要的 URL,但我无法进一步返回它......这是我目前的代码:
public ActionResult UploadPhoto(Image img, HttpPostedFileBase file, ProfilePageModel model)
{
var currentUser = CommunitySystem.CurrentContext.DefaultSecurity.CurrentUser;
bool isAccepted = false;
string fileName = string.Empty;
if (file.ContentLength > 0)
{
string fName = System.Guid.NewGuid().ToString();
// Generate each version
foreach (string fileKey in System.Web.HttpContext.Current.Request.Files.Keys)
{
HttpPostedFile uploadFile = System.Web.HttpContext.Current.Request.Files[fileKey];
// Generate a filename (GUIDs are best).
fileName = Path.Combine("~/uploads/", fName + format);
// Let the image builder add the correct extension based on the output file type
ImageBuilder.Current.Build(uploadFile, fileName, new ResizeSettings(
"width=300;format=jpg;mode=max;crop=20,20,80,80;cropxunits=100;cropyunits=100"));
model.fileName = fileName;
}
return RedirectToAction("EditProfile");
}
return RedirectToAction("EditProfile");
}
当我运行这个“上传文件并按提交”时,我得到模型为空,模型包含有关名称、您来自哪个国家等配置文件的信息。
我需要以某种方式向我的模型添加值,以便我可以返回它(所以它不会崩溃)。有任何想法吗?