Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 119375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:38:35+00:00 2026-05-11T03:38:35+00:00

I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery

  • 0

I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery which grabs my form values and posts them to a controller action. If I run this call without AJAX in a normal form post scenario, everything comes through correctly. However, once I incorporate the jQuery code, all the form values EXCEPT the files come through. Request.Files() returns nothing. Is there an additional piece I am missing here?

HTML code:

<form action='/Images/AddImages/' enctype='multipart/form-data' id='frmAddImages' method='post'>     <%=Html.Hidden('hfPromoId',ViewData.Model.Promotion.PromoId) %>     <table>         <tr>             <td>Images for Promo: </td>             <td><span class='promoTitle'><%=Html.Encode(ViewData.Model.Promotion.PromoName) %></span></td>         </tr>         <tr class='newImageContainer'>             <td>Select Image:</td>             <td>                 <input type='file' id='txtImagePath' name='txtImagePath' />             </td>         </tr>         <tr class='newImageContainer'>             <td>Image Caption:</td>             <td>                 <input id='txtImageCaption' name='txtImageCaption' />             </td>         </tr>         <tr>             <td><input type='submit' value='Save Image' id='AddImages' /></td>              </tr>     </table>  </form>  

Controller code:

[AcceptVerbs(HttpVerbs.Post)] public ActionResult AddImages(bool? partial) {     int promoId = Convert.ToInt32(Request.Form['hfPromoId']);     var promo = _promoRepository.GetPromotion(promoId);      string imageCaption = Request.Form['txtImageCaption'].ToString();     string imagePath = string.Empty;      foreach (string file in Request.Files)     {         HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;          if (hpf.ContentLength == 0)         { continue; }          imagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @'Content\PromoImages',                                             promo.PromoId.ToString() + '__' + Guid.NewGuid().ToString() + Path.GetFileName(hpf.FileName));         hpf.SaveAs(imagePath);     }      _promoRepository.SaveImageForPromo(promoId, imageCaption, imagePath, this.Request);      if (partial == true)     {         return List(true, promoId);     }      return View('Images', GetModel(promoId)); } 

jQuery code:

$(document).ready(function() {         $('#frmAddImages').submit(function() {             runAjax(form, updateImageList, 'html');             return false;         }); });   function runAjax(form, callback, format) {     $.ajax({         url: form.action + '?partial=true',         type: form.method,         dataType: format,         data: $(form).serialize(),         success: callback     }); }  function updateImageList(result) {     $('#gallery').html(result);     setElementStyling(); } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:38:36+00:00Added an answer on May 11, 2026 at 3:38 am

    Yea, that makes sense, jquery serialize isn’t going to process file upload data. You’re going to want to look at some sort of plugin to handle the fileupload. I did some google searching for it and only turned up plugins that allowed styling of the browse button. you may have to take an iframes or silverlight route.

    Update As noted in the comment their is a jQuery Form plugin that supports file upload.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ASP.NET MVC Beta on our web server running a few apps. My
I have an ASP.NET MVC 3 Beta application running on IIS. In my web.config
-- Running within ASP.NET MVC alongside jQuery -- I'm using jQuery to render a
I've been running through the ASP.Net MVC C# Movie Database tutorial, but been trying
I have an Asp.net MVC application running on AppHarbor. It has the everyday email
I have an ASP.NET MVC web application running in IIS as a subweb; let's
I'm running ASP.NET MVC 2 Preview 2 (With VS 2010 Beta 2) using Entity
I have this web app that is running ASP .NET MVC 1.0 with LINQ
I have an ASP.NET MVC application running on IIS7. I use sessions to keep
I have an ASP.NET MVC application up and running, using a SQL Sever express

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.