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 6182635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:13:59+00:00 2026-05-24T01:13:59+00:00

Hi Im having some issues getting a file attaced to a form to submit

  • 0

Hi Im having some issues getting a file attaced to a form to submit on jquery .post().

What i want to do is, user choose a file / the form submit using jquery .post(). I got it working fine if i just do a .submit() on the whole form, but i dont want to use it because of other content on the site. here is the code i use now. what this does is use a button as file input and i do the submit on the choose function right away.

$('.upload').file().choose(function (e, input) {                
            input.attr('name', 'firstPicture');
            input.hide();

            $(input).appendTo('#myForm');

            $('#hiddenDiv').show();

            $.post("/Home/UploadSingelFile", $("#myForm").serialize());
            return false;
        });

my action is correct public ActionResult UploadSingelFile(HttpPostedFileBase firstPicture)

what happends when i do like above is that the firstPicture input is null, but like i said if i do the submit its ok.

if this is not possible do im thinking of doing a .submit() but then i need to return a partialview and how would i go about to update that partialview into a div on the return? just like microsofts ajax.form got a updatetarget (i dont want to use their ajax form)

  • 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. Editorial Team
    Editorial Team
    2026-05-24T01:13:59+00:00Added an answer on May 24, 2026 at 1:13 am

    When sending an AJAX request using jQuery you are simply sending a application/x-www-form-urlencoded request to the server whereas in order to upload a file you need to use a multipart/form-data request.

    There are some plugins such as jquery form which emulate this functionality by using a hidden iframe. So basically you will write the following to ajaxify the form containing file inputs:

    $(function() {
        $('#myForm').ajaxForm(function(result) {
            // do something with the results when the form is submitted
        });
    });
    

    and then when you need to submit the form:

    $('#myForm').ajaxSubmit();
    

    or simply when the user presses the submit button.

    There are also other plugins such as Uploadify and Plupload which would allow yoiu to achieve the same (Uploadify for example uses Flash, while Plupload detects what the client supports: Flash, Silverlight and if not it may fallback to hidden iframes to simulate the file upload).

    But you may simply forget about uploading files with $.post.


    UPDATE:

    As @Can Gencer points out in the comments section there’s also the Ajax upload plugin which could be used.

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

Sidebar

Related Questions

We are having some issues getting SharePoint to work as we want it to.
I am using Fluent NHibernate and having some issues getting a many to many
I'm having some issues getting my pdf file to display in my jsp page.
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it
I am having some issues with using the OrderBy extension method on a LINQ
I'm having some inheritance issues as I've got a group of inter-related abstract classes
Having some issues getting this MPMoviePlayerViewController to work. I have two sample URLs pointing
I am having some issues getting tiles to load into my MapView in android
I'm having some issues deploying a Visio addin. Running the VSTO file works on
I'm having some issues getting high resolution tab bar icons displaying correctly for iPhone

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.