Click here to Skip to main content
13,901,044 members
Rate this:
Please Sign up or sign in to vote.
See more:

I have a form with one upload control and some text fields.

i am sending the formdata values to the controller with ajax.

Here am facing one problem i.e am able to get the formdata values in IE and Mozilla but not in chrome. Please let me know the reason.

Here is my code snippet.

var fileUpload = $("#file").get(0);

 var files = fileUpload.files;

 var fileData = new FormData();

for (var i = 0; i < files.length; i++)

    fileData.append(files[i].name, files[i]);

 fileData.append("textfield1", $('#textfield1').val());

 fileData.append("textfield2", $('#textfield2').val());

 fileData.append("textfield3", $('#textfield3').val());

 fileData.append("textfield4", $('#textfield4').val());
xhr = $.ajax({

                url: 'Home/Index',

                type: 'POST',

                dataType: "JSON",

                contentType: false, // Not to set any content header 

                processData: false, // Not to process data 

                data: fileData

Thanks in advance.

What I have tried:

I tried with IE and Mozilla it is working fine.
Updated 29-Jun-16 6:29am
Richard Deeming 29-Jun-16 12:17pm
Chrome has supported FormData since version 7. If your code works in IE and Firefox, it should also work in Chrome.

You'll need to debug your code to see what's going wrong.

You could also try disabling any Chrome extensions you have installed, in case one of them is interfering with the script.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

To start with, check out compatibility chart: FormData — Web APIs | MDN.

See the section "Browser compatibility".


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190306.1 | Last Updated 29 Jun 2016
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100