mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-14 15:41:10 +00:00
Test that uploaded image is an image file, return error otherwise
- New javascript function inventreeFileUpload
This commit is contained in:
@@ -153,7 +153,7 @@
|
||||
{
|
||||
accept_text: 'Activate',
|
||||
accept: function() {
|
||||
inventreeUpdate(
|
||||
inventreePut(
|
||||
"{% url 'api-part-detail' part.id %}",
|
||||
{
|
||||
active: true,
|
||||
@@ -176,7 +176,7 @@
|
||||
{
|
||||
accept_text: 'Deactivate',
|
||||
accept: function() {
|
||||
inventreeUpdate(
|
||||
inventreePut(
|
||||
"{% url 'api-part-detail' part.id %}",
|
||||
{
|
||||
active: false,
|
||||
|
@@ -108,47 +108,22 @@
|
||||
|
||||
var files = transfer.files;
|
||||
|
||||
console.log('dropped');
|
||||
|
||||
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(
|
||||
inventreeFileUpload(
|
||||
"{% url 'part-image-upload' part.id %}",
|
||||
formData,
|
||||
file,
|
||||
{},
|
||||
{
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(data, status, xhr) {
|
||||
location.reload();
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
showAlertDialog('Error uploading image', renderErrorMessage(xhr));
|
||||
}
|
||||
}
|
||||
);
|
||||
*/
|
||||
|
||||
console.log('submitted');
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user