The first is the best approach. The reason for that is because this will make the action easier to unit test and it doesn't rely on magic strings.
Image Uploading There are Several Approaches. When to choose one over others?
-
23-03-2022 - |
Question
Currently I'm working with image uploading using MVC3. When I did some searches for sample code I found out several approaches. I figured out almost 3 methods. Can someone explain which one is better over the other or all of them are the same? An explanation when it comes to performance or anything is welcome.
Method 1: As parameter
public ActionResult UploadImage(HttpPostedFileBase img)
{
return View();
}
Method 2: From Request.Files
HttpPostedFileBase imgFile= Request.Files["img"];
Method 3: From Image Helper
var imgFile= WebImage.GetImageFromRequest();
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow