Ajax删除Dropzone Laravel POST数据上的链接为空结果

时间:2019-02-28 09:22:36

标签: php jquery laravel laravel-5 dropzone

我使用Dropzone创建了多个上传文件,并通过ajax请求添加了删除链接,但是当我在此处{strong> POST 进行echo json_encode($_POST);时, 结果为空。有人有什么解决办法吗?

这是我的以下代码:

var token = $('[name=_token').val();
    Dropzone.autoDiscover = false;
    var imageUpload= new Dropzone(".dropzone",{
        url: "{{ route('saveImages') }}",
        maxFilesize: 2,
        method:"post",
        acceptedFiles:"image/*",
        paramName:"image",
        dictInvalidFileType:"Type file ini tidak dizinkan",
        addRemoveLinks:true,
        headers : {
            'X-CSRF-Token' : token
        }
    });

    //Event ketika Memulai mengupload
    imageUpload.on("sending",function(file, xhr, formData){
        var token_upload = 1337;
        formData.append("token_upload" , token_upload);
    });

    imageUpload.on("removedfile",function(formData){
        $.ajax({
            data    : { "token_upload":1337 },
            type    : "POST",
            url     : "{{ route('removeImages') }}",
            cache   : false,
            processData: false,
            contentType: false,
            dataType: 'json',
            beforeSend: function (request) {
                return request.setRequestHeader('X-CSRF-Token', "{{ csrf_token() }}");
            },
            success: function(data)
            {
                console.log("Foto terhapus");
            },
            error: function()
            {
                console.log("Error");
            }
        });
    });

0 个答案:

没有答案