javascript - Declaring new formData() while Image uploading using PHP and jQuery -


i trying upload image using php , jquery, following javascript error:

typeerror: 'append' called on object not implement interface formdata.
...d=[],e=function(a,b){b=n.isfunction(b)?b():null==b?"":b,d[d.length]=encodeuricom...

what wrong code?

html:

<form id="uploadform" name="form_movie" method="post" action="index.php" class="form form-default">  <input id="file-upload" name="userimage" type="file" class="inputfile" /> <input id="upload-image" type="button" value="upload image" class="btnsubmit" /> 

jquery:

$(document).ready(function (e) { $( "#upload-image" ).click(function( e ) {      var file_data = $('#file-upload').prop('files')[0];        var form_data = new formdata();                       form_data.append('file-upload', file_data);     // alert('s'+imagedata);     console.log(form_data);         movie_name = $('#movie_name').val();          if (movie_name == '') {             alert('movie name canot empty');         } else {             $.ajax({                 url: "up.php",                 type: "post",                 data:  form_data,                 success: function(data)                 {                     $("#targetlayer").html(data);                 },                 error: function()                  {                 }                       });         }  }); }); 

to upload file using $.ajax need set processdata option false , contenttype option false

    $(document).ready(function (e) { $( "#upload-image" ).click(function( e ) {      var file_data = $('#file-upload').prop('files')[0];        var form_data = new formdata();                       form_data.append('file-upload', file_data);     // alert('s'+imagedata);     console.log(form_data);         movie_name = $('#movie_name').val();          if (movie_name == '') {             alert('movie name canot empty');         } else {             $.ajax({                 url: "up.php",                 type: "post",                 data:  form_data,                 processdata: false,                 contenttype: false,                 success: function(data)                 {                     $("#targetlayer").html(data);                 },                 error: function()                  {                 }                       });         }  }); }); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -