mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-14 15:41:10 +00:00
POST image data to View
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects - https://stackoverflow.com/questions/25390598/append-called-on-an-object-that-does-not-implement-interface-formdata#25390646
This commit is contained in:
@@ -110,7 +110,47 @@
|
||||
|
||||
console.log('dropped');
|
||||
|
||||
//$(this).removeClass('dragover');
|
||||
if (files.length > 0) {
|
||||
var file = files[0];
|
||||
|
||||
var formData = new FormData();
|
||||
|
||||
var token = getCookie('csrftoken');
|
||||
|
||||
formData.append('file', file);
|
||||
|
||||
$.ajax({
|
||||
beforeSend: function(xhr, settings) {
|
||||
xhr.setRequestHeader('X-CSRFToken', token);
|
||||
},
|
||||
url: "{% url 'part-image-upload' part.id %}",
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data, status, xhr) {
|
||||
//location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.log('Error uploading thumbnail: ' + status);
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
inventreeUpdate(
|
||||
"{% url 'part-image-upload' part.id %}",
|
||||
formData,
|
||||
{
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
}
|
||||
);
|
||||
*/
|
||||
|
||||
console.log('submitted');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$("#show-qr-code").click(function() {
|
||||
|
Reference in New Issue
Block a user