【问题标题】:how to add files added to the dropzone and send them in an ajax request as if they were input file fields如何添加添加到 dropzone 的文件并将它们发送到 ajax 请求中,就好像它们是输入文件字段一样
【发布时间】:2020-11-23 20:20:09
【问题描述】:

我想接收 formData 中的文件并发送一个 ajax 请求,我希望服务器接收它,就好像它是一个输入文件字段一样。

我试过这个:Add files from Dropzone to form

但是当我发出请求时,我的服务器无法将其识别为输入文件字段

$.ajax({
        url: args.url,
        data: formData, /*I want the file inside this formData */
        success: function(data){
            
        }, error: function() {

        }
    });

【问题讨论】:

标签: javascript jquery ajax dropzone


【解决方案1】:

您可以尝试将 processData : falsecontentType : false 添加到您的 ajax

如下:

$.ajax({
        url: args.url,
        data: formData, /*I want the file inside this formData */
        processData : false,
        contentType : false,
        success: function(data){
            
        }, error: function() {

        }
});

【讨论】:

    猜你喜欢
    • 2023-03-14
    • 2013-03-12
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多