Attempt at fixing file upload
This commit is contained in:
+19
-23
@@ -94,41 +94,37 @@ function save(partID) {
|
|||||||
|
|
||||||
partnos = partno_v.split(' ');
|
partnos = partno_v.split(' ');
|
||||||
|
|
||||||
if (datasheet.length == 0) {
|
var data = new FormData();
|
||||||
datasheet = [];
|
|
||||||
datasheet[0] = '';
|
if (datasheet.length == 1)
|
||||||
}
|
data.append('datasheet-file', datasheet[0]);
|
||||||
|
data.append('block', block_v);
|
||||||
|
data.append('partno', partnos[0]);
|
||||||
|
if (partnos.length > 1)
|
||||||
|
data.append('partnoalt', partnos[1]);
|
||||||
|
if(partnos.length > 2)
|
||||||
|
data.append('partnoalt2', partnos[2]);
|
||||||
|
data.append('description', description_v);
|
||||||
|
data.append('quantity', quantity_v);
|
||||||
|
data.append('notes', notes_v);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
// Your server script to process the upload
|
// Your server script to process the upload
|
||||||
url: 'https://www.elab.kth.se/parts/alter/' + partID,
|
url: 'https://www.elab.kth.se/parts/alter/' + partID,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
||||||
data: {
|
data: data,
|
||||||
file: datasheet[0],
|
|
||||||
block: block_v,
|
|
||||||
partno: partnos[0],
|
|
||||||
partnoalt: partnos[1],
|
|
||||||
partnoalt2: partnos[2],
|
|
||||||
description: description_v,
|
|
||||||
quantity: quantity_v,
|
|
||||||
notes: notes_v
|
|
||||||
},
|
|
||||||
|
|
||||||
// Tell jQuery not to process data or worry about content-type
|
// Tell jQuery not to process data or worry about content-type
|
||||||
// You *must* include these options!
|
// You *must* include these options!
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
|
success: function(data) {
|
||||||
|
var datasheet_par = '<p id="datasheet-info"><i class="fa fa-check"></i></p>';
|
||||||
|
$('#datasheet-info').replaceWith(datasheet_par);
|
||||||
|
},
|
||||||
|
|
||||||
// Custom XMLHttpRequest
|
|
||||||
xhr: function() {
|
|
||||||
var xhr = $.ajaxSettings.xhr();
|
|
||||||
xhr.upload.onload = function(){
|
|
||||||
var datasheet_par = '<p id="datasheet-info"><i class="fa fa-check"></i></p>';
|
|
||||||
$('#datasheet-info').replaceWith(datasheet_par);
|
|
||||||
} ;
|
|
||||||
return xhr;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<div class="details-content"><p id="datasheet-info"></p></div>
|
<div class="details-content"><p id="datasheet-info"></p></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="round-button"><a href="#" id="edit_button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
<div class="round-button"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
||||||
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||||
<!--<h2 class="card-id"></h2>
|
<!--<h2 class="card-id"></h2>
|
||||||
<input type="text" name="name" placeholder="Name" id="name"><br><br>
|
<input type="text" name="name" placeholder="Name" id="name"><br><br>
|
||||||
|
|||||||
Reference in New Issue
Block a user