Nil
Nil

Reputation: 176

How to save uploaded images into different folders in mvc.net?

I have 4 upload textboxes and one submit button I want to save 4 images into 4 folders depending on textbox sequence.

Problems I am facing are:

I get file using HttpPostedFileBase so I can't differentiate which file came from which text box.

Upvotes: 1

Views: 455

Answers (1)

REDEVI_
REDEVI_

Reputation: 684

you can have 4 different input controls with 4 different names and in controller 4 different file bases ... and based on the control name you can save it to different folders

In your View

<input type="file" name="file1" />
<input type="file" name="file2" />
<input type="file" name="file3" />
<input type="file" name="file4" />

In your Controller

[HttpPost]
public ActionResult FileUpload(HttpPostedFileBase file1,HttpPostedFileBase file2,HttpPostedFileBase file3,HttpPostedFileBase file4)
{

}

Upvotes: 1

Related Questions