I have a classified ad View Model that is defined as:
public class ClassifiedAd
{
public int ClassifiedAdId { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public HttpPostedFileBase ImageFile { get; set; }
}
As you can see, users can upload an image for the ad. This works fine during the creation of the ad.
However suppose I want to allow users to edit their classified ad, including the uploaded image. How am I supposed to populate the ImageFile
property with the currently uploaded file when the HttpPostedFileBase
class is abstract? How do I properly display the currently uploaded image and prevent the user from deleting it unintentionally and/or allow them to delete it properly?
Is there a way to create an instance of HttpPostedFileBase
from a MemoryStream
of byte array
that I'm missing here or is there some other way to deal with this issue?