Sencha enctype="multipart/form-data"에서 파일 여러개 처리하기

2025. 1. 27. 22:15Javascript/Sencha

'Content-Type': null 설정

동일한 이름으로 파일 객체를 추가

const formData = new FormData();
formData.append('param1', 'abc');
formData.append('param2', '111);
formData.append('_csrf', document.getElementById('_csrf').innerText);

// Add files to the form data
newRows.forEach(record => {
    formData.append('files', record.file); // Use 'files' as the key
});

Ext.Ajax.request({
    url: '/url',
    rawData: formData,
    headers: {
        'Content-Type': null // Let the browser handle the multipart boundaries
    },
    success: function(response) {
        console.log('File upload successful');
    },
    failure: function(response) {
        console.error('File upload failed');
    }
});