1

I have the following HTML code:

<table>
  <tr>
    <td>Your photo file</td>
    <td ><input id="EmpSelfPhoto" type="file" /></td>
    <td style='color:red'>Not requiered</td>
    </tr>
  
   <tr>
    <td>Your CV file</td>
    <td><input id="EmpCV" type="file" /></td>
     <td style='color:red'>Requiered</td>
    </tr>
  <tr>
    <td></td>
    <td><input id="PostFile" type="button" value="Upload .." /></td>
    <td></td>
    </tr>
  </table>

And I'm using Jquery ajax -generic handler to upload the posted files. The problem is context.Request.Files.Count will validate for all inputs and I have to loop throw all input using HttpFileCollection.


How can I validate each file input separately in server side? For example I would like to check if file input 1 has file, and check if file input 2 is a valid picture.
Green Falcon
  • 818
  • 3
  • 17
  • 48
Eid Sky
  • 49
  • 6
  • The enumerator for the HttpFileCollection gives you the names given to each HTML input control. You should give each input a unique name attribute. See [this SO page](http://stackoverflow.com/questions/1760510/foreach-on-request-files) on the topic. – Dan Wilson Dec 11 '16 at 18:12
  • @DanWilson i couldn't handle HttpPostedFileBase, i'm using webforms btw.. – Eid Sky Dec 11 '16 at 22:50

0 Answers0