I'm getting in controller as parameter image upload and I need to copy that image so I can manipulate on copy not on original. How can I copy image in mvc?
[HttpPost]
public ActionResult Create(HttpPostedFileBase photo)
{
var copiedImage = ...
}
I'm getting in controller as parameter image upload and I need to copy that image so I can manipulate on copy not on original. How can I copy image in mvc?
[HttpPost]
public ActionResult Create(HttpPostedFileBase photo)
{
var copiedImage = ...
}
You can use the SaveAs()
function of the HttpPostedFileBase
class to store the image on the server on a separate location and then manipulate it.
See this SO post
In the second post there is a piece of code to copy the file to another stream
using (MemoryStream ms = new MemoryStream()) {
file.InputStream.CopyTo(ms);
byte[] array = ms.GetBuffer(); }