I'm using this bootstrap-file-input
I'm trying to change the uploadExtraData
before uploading multiple files.
Here is my code
$("#input-id").fileinput({
uploadUrl: '@Url.Action("DAR", "Upload")',
allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg', 'bitmap', 'zip', 'docx', 'doc', 'pdf', 'pptx', 'xlsx', '7zip'],
uploadExtraData: { Action: '', LAT: 0, LONG: 0, DateModified: '0', filename_text: '', SelectedTaskID: 0 }
}).on('fileloaded', function (event, file, previewId, fileId, index, reader) {
}).on('filepreupload', function (event, data, previewId, index, fileId) {
var id = GetURLParameter('id');
$.each(data.files, function (a, b) {
var temp_name = b.size + "_" + b.name;
if (temp_name == fileId) {
data.extra.Action = 'during';
data.extra.DateModified = b.lastModified;
data.extra.filename_text = b.name;
data.extra.SelectedTaskID = id;
EXIF.getData(b, function () {
var rawLAT = EXIF.getTag(this, "GPSLatitude");
var rawLONG = EXIF.getTag(this, "GPSLongitude");
if (typeof rawLAT === 'string') {
var LAT = rawLAT.split(",");
var Long = rawLONG.split(",");
LAT[0] = LAT[0] ? LAT[0] : 0;
LAT[1] = LAT[1] ? LAT[1] : 0;
LAT[2] = LAT[2] ? LAT[2] : 0;
Long[0] = Long[0] ? Long[0] : 0;
Long[1] = Long[1] ? Long[1] : 0;
Long[2] = Long[2] ? Long[2] : 0;
data.extra.LAT = Number(LAT[0]) + (Number(LAT[1]) / Number(60.0)) + (Number(LAT[2]) / Number(3600.0));
data.extra.LONG = Number(Long[0]) + (Number(Long[1]) / Number(60.0)) + (Number(Long[2]) / Number(3600.0));
} else {
data.extra.LAT = 0;
data.extra.LONG = 0;
}
});
}
});
}).on('fileuploaded', function (e, params) {
//img_arr.push(params.response.fileid);
});
What happened is after I modified the uploadExtraData. The data will be applied on the next upload file request and not the current one.