1

I have this simple snippet in which I wnat to add a selected file from a inputfield in FormData-Object, but whatever I do, a data.toSource() always returns nothing.

Can someone tell me, what I'm doing wrong?

http://jsfiddle.net/ktcjjff4/

$(document).ready(function() {

$('#basicUploadFile').live('change', function () {        

    data = new FormData();

    for (var i = 0; i < this.files.length; i++)  {
        data.append('userfile', this.files[i].name);
        alert(this.files[i].name);
    }

    alert(data.toSource());       


    });    

});
AdmiralCrunch
  • 153
  • 12

1 Answers1

1

The data.toSource() is not a function in Chrome or Safari. It should have been:

data.toString();  // OR
JSON.stringify(data);

Also toSource() does not work in Internet Explorer or Safari. It is Gecko-only. See Implementing Mozilla's toSource() method in Internet Explorer for alternatives.

Community
  • 1
  • 1
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252