Let me try to explain my situation as simple as possible first:
Suppose I have a page which contains multiple [input type=’File’]. Some of them may be selected a file and some are not.
In my httppost method, I know I need to use parameter like “IEnumerable files” to get filenames, and also each [input] name I should define either = ‘files’ or ‘files[0]’,’files[1]’, etc…..
My question is: when getting a list of HttpPostedFileBase, how could I determine which file belongs to which input control? As some inputs may leave blank.
Also because these [input] are created dynamically and there is no fixed number of it, I could not hard-code the parameter in httppost method for each of them.
Try this solution:
View:
Controller:
The “uploaded” anonymouse type will contains file belonging to input control name, and will conatins only input names which selected