0

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 = ...
}
user1765862
  • 13,635
  • 28
  • 115
  • 220

1 Answers1

0

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

File Upload ASP.NET MVC 3.0

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(); }
Community
  • 1
  • 1
Naveed Butt
  • 2,861
  • 6
  • 32
  • 55