Javascript 在使用PHP和jQuery上载图像时声明新的formData()

Javascript 在使用PHP和jQuery上载图像时声明新的formData(),javascript,php,jquery,Javascript,Php,Jquery,我正试图使用PHP和jQuery上传图像,但出现以下javascript错误: TypeError:对未实现接口FormData的对象调用了“append”。 …d=[],e=函数(a,b){b=n.isFunction(b)?b():null==b?”:b,d[d.length]=encodeURICom… 我的代码有什么问题 HTML: 要使用$.ajax上传文件,需要将processData选项设置为false,将contentType选项设置为false $(document).

我正试图使用PHP和jQuery上传图像,但出现以下javascript错误:

TypeError:对未实现接口FormData的对象调用了“append”。
…d=[],e=函数(a,b){b=n.isFunction(b)?b():null==b?”:b,d[d.length]=encodeURICom…

我的代码有什么问题

HTML:


要使用$.ajax上传文件,需要将processData选项设置为false,将contentType选项设置为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 be empty');
        } else {
            $.ajax({
                url: "up.php",
                type: "POST",
                data:  form_data,
                processData: false,
                contentType: false,
                success: function(data)
                {
                    $("#targetLayer").html(data);
                },
                error: function() 
                {
                }           
           });
        }

});
});
$(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 be empty');
        } else {
            $.ajax({
                url: "up.php",
                type: "POST",
                data:  form_data,
                success: function(data)
                {
                    $("#targetLayer").html(data);
                },
                error: function() 
                {
                }           
           });
        }

});
});
    $(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 be empty');
        } else {
            $.ajax({
                url: "up.php",
                type: "POST",
                data:  form_data,
                processData: false,
                contentType: false,
                success: function(data)
                {
                    $("#targetLayer").html(data);
                },
                error: function() 
                {
                }           
           });
        }

});
});