HttpPostedFileBase is null

4 posts, 0 answers
  1. Steven
    Steven avatar
    29 posts
    Member since:
    Jul 2012

    Posted 11 Oct 2012 Link to this post

    *** SOLUTION FOUND (see EDIT below) ***

    I have followed some of the examples for declaring my MVC controller method for use with the Upload component.  My upload handler declaration is as follows:

    public ActionResult Upload(IEnumerable<HttpPostedFileBase> attachments, long inventoryID, long imageType)

    I have set my Upload control to use Async.  However, whenever I try to upload a file, the attachments parameters is always passed null.

    I have also tried:
    • Renaming attachments to files
    • Declaring IEnumerable<HttpPostedFileBase> as IEnumerable<HttpPostedFile>
    • Declaring the attachments parameter as both HttpPostedFileBase and HttpPostedFile (singular

    I have written some JavaScript (as the Upload event) to pass the additional parameters (inventoryID and imageType) which are always passed successfully.

        function imageUploadUpload(e) {
   = { inventoryID : @Model.InventoryID, imageType: imageType };

    I have tried removing the Upload event/handler to see if this makes a difference, but still have the same problem.

    Any idea what is going on?

    Thank you.

    *** EDIT ***

    I found the solution here.  The name of the Upload component must match the name of the parameter that holds the HttpPostedFileBase.  I had named my Upload component imageUpload.  When I renamed the parameter to imageUpload, it worked fine!

  2. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 12 Jun 2013 Link to this post

    I ran into this exact same issue.

    I can confirm that after naming the parameter in the controller the exact same name as what I named the KendoUI upload control, it worked.  Thanks Steven.
  3. Soori
    Soori avatar
    7 posts
    Member since:
    Jun 2013

    Posted 06 Aug 2013 Link to this post

    Thanks. That solved my issue .
  4. Soori
    Soori avatar
    7 posts
    Member since:
    Jun 2013

    Posted 17 Mar 2014 in reply to Bill Link to this post

    Name attribute of the  KendoUI upload control should be same as the parameter name of Controller. In following example it is 'fille'

    <input name="file" id="fileUploader" type="file" />

     public ActionResult UploadFile(HttpPostedFileBase file, String subject, String doc, String ref)
Back to Top