Cloudflare阻止AJAX文件上传FormData

时间:2019-06-07 12:04:13

标签: jquery ajax cloudflare

我遇到了CloudFlare阻止我的AJAX调用以使用以下方法上传图像的问题。我知道这是CloudFlare中的问题,因为未通过CloudFlare路由的其他站点运行正常。

// Perform AJAX check on Image to ensure dimensions meet our minimum requirement
var theForm = $('#upload_image_form')[0];
var theFormData = new FormData(theForm);
// We need to know if this is a Home page banner or Page banner
if ($('#PAGE_ID').val() == '') {
    banner_type = 'home';
} else {
    banner_type = 'page';
}
theFormData.append('banner_type',banner_type);
$.ajax({
    url: "ajax_banner_image_check.php",
    type: "POST",
    data: theFormData,
    contentType: false,
    cache: false,
    processData: false,
    success: function(result) {
         console.log(result);
    }
});

您知道我需要做什么才能完成这项工作吗?基本上,映像文件已损坏,并且另一端使用该文件并使用imagecreatefrom [extension]处理该文件的PHP脚本死亡,并抛出错误,指出该映像文件无效。

我是否需要禁用CloudFlare中的特定功能才能使其正常工作,还是可以在请求中添加一些内容以使其通过而不会被视为潜在恶意?

我已经遍历了formData var,并回显到控制台以确保其设置正确。

0 个答案:

没有答案