0👍
✅
In your template file input has id="file_id" but in your function you call
data.append('file', document.getElementById('file').files[0]);
Change to document.getElementById(‘file_id’).files[0])
Source:stackexchange.com