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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:16:06+00:00 2026-05-26T20:16:06+00:00

We are submitting an asp.net mvc view form using the knockoutjs postJson util. All

  • 0

We are submitting an asp.net mvc view form using the knockoutjs postJson util. All works fine but now we want to add a file upload option in the form.

As per Uploading file in asp.net mvc, we added the elements and the enctype=”multipart/form-data” attribute in the Form but we do not get any files in the Request.Files collection in the Controller

Is there any issue using ko.utils.postJson? Is there any better way to upload files along with my form data?

  1. All my elements are using KO binds so cannot remove knockout
  2. We used postJson so that it can simulate a form submission and the controller can redirect to another view
  • 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-26T20:16:07+00:00Added an answer on May 26, 2026 at 8:16 pm

    The postJson src is doing a JSON.stringify on each input it creates and inserting it as an input element in to an internal form element:

    for (var key in data) {
        var input = document.createElement("INPUT");
        input.name = key;
        input.value = ko.utils.stringifyJson(ko.utils.unwrapObservable(data[key]));
        form.appendChild(input);
    }
    

    As such, file data from a file input cannot be loaded via javascript to be posted via the postJson call as it currently exists so your best bet for that would be to just upload the files and post the JSON in two separate requests. It may also be possible to inject the file input into this form the postJson method creates (by overriding the method) but its kind of hacky and may not be forward compatible.

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

Sidebar

Related Questions

I have a problem on submitting an asp.net mvc form that is using Xval
How to invoke Form Validation Javascript methods before submitting ASP.NET MVC view?
I have a ASP.NET MVC 3 view with esentially two forms, but which reside
I am using ASP.NET MVC 1.0. I am creating a view to Create a
i m using asp.net mvc2 and i m submitting a form through ajax using
i have a form in Asp.net MVC. On submitting i want to generate the
I'm using asp.net mvc 3 with unobtrusive jquery validation. I have a form that
What is the best practice for submitting forms in ASP.NET MVC? I have been
I am using ASP.net MVC 2.0 , i have used a textarea on my
I have an ASP.Net MVC Page with a very simple form on it: One

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.