After spending several hours searching and experimenting, I finally found a solution that worked for me:
//insert image
document.getElementById("btnAddImg").addEventListener('click', function () {
// Create the picker object and specify options
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);
openPicker.pickSingleFileAsync().then(function (file) {
file.openAsync(Windows.Storage.FileAccessMode.read).done(function (stream) {
var fileType = file.contentType;
var blob = MSApp.createBlobFromRandomAccessStream(fileType, stream);
var fdata = new FormData();
fdata.append('upload_field', blob);
//additional code....
});
});
});
I hope this solution can assist others facing similar challenges.