I am trying to do upload attachment functionality using MVC. My method that is actually doing the upload/save attachment is expecting a HttpPostedFileBase type.
public virtual string Upload(HttpPostedFileBase fileName)
{
//Code to upload/save attachment.
}
My problem is “fileName” is being passed from the UI as a string. How can I convert the string(file path name) into something my Upload method can work with.
Thanks in advance.
As mentioned by others, your form should look something like this:
Then as you mentioned you are trying to post via ajax, you can use jQuery serialize() to serialize the formData to be pushed to your controller.