1let data = {
2 'file': file,
3 'fileName': file.name,
4};
5// You have to download 3rd Cookies library
6// https://docs.djangoproject.com/en/dev/ref/csrf/#ajax
7let csrftoken = Cookies.get('csrftoken');
8let response = fetch("/upload/", {
9 method: 'POST',
10 body: JSON.stringify(data),
11 headers: { "X-CSRFToken": csrftoken },
12})
13