How to send HttpPostedFile to an action in some controller

274 views Asked by At

If you want to send an object of type HttpPostedFile to an action, you may get null object in the action. So how to send it?

1

There are 1 answers

1
محسن عباسی On

To do this, you may need send HttpPostedFile via Temp Data. For a sample, see the following:

HttpPostedFileBase file;
TempData["FilePosted"] = file;

And in the action, do this:

HttpPostedFileBase file = (HttpPostedFileBase)TempData["FilePosted"];