Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deekepMaks's avatar

TypeError: Can only call Blob.slice on instances of Blob

ajax:

  $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    let inputWithFileID = $(input).attr('data-input-id');
    let image = $('#' + inputWithFileID).prop('files');

    $.ajax({
        type: 'POST',
        url: '/profile/edit/setBackground',
        data: {
            points: $('#bgImageCroppie').croppie('get'),
            image: image
        },
        success: (data) => {
           ///
        },
        error: (data) => {
            ///
        }
    });

HTML:

<div class="mb-3">
                                    <input class="form-control" type="file" onchange="previewImage(this);" data-preview-block-id="bgImageCroppie" id="bgFile" accept="image/png, image/jpeg">
                                </div>
                                <div class="col-12 text-end">
                                    <button type="submit" class="btn btn-sm btn-primary mb-0" data-input-id="bgFile" onclick="setBackground(this)">Save</button>
                                </div>

An error: TypeError: Can only call Blob.slice on instances of Blob

I tried to use processdata:false and contenttype: false, but then an empty request came

0 likes
0 replies

Please or to participate in this conversation.