0

I was following this example: Sending multipart/formdata with jQuery.ajax but I got a Uncaught TypeError: Illegal invocation. I was wondering what went wrong. The following is the code I'm using:

  upload()
  {
    var dataimg = new FormData();
    dataimg.append('file', $("#file")[0].files[0]);

    $.ajax({
        url: "src/php/upload.php",
        type: "post",
        cache : false,
        contentType : false,
        processType : false,
        data: dataimg,
        success: function(data) {
          //this.setState({data : JSON.parse(data)});
          console.log(data);
        }
    });
  }
Community
  • 1
  • 1
A. L
  • 11,695
  • 23
  • 85
  • 163

0 Answers0