function getFileContentsAndMetadata(entityID) {
// Get the name of the selected file
var fileName = encodeURIComponent(document.getElementById('file-upload').files[0].name);
// Get the content of the selected file
var file = document.getElementById('file-upload').files[0];
// If the user has selected a file
if (file) {
// Read the file as a byte array
var reader = new FileReader();
reader.readAsArrayBuffer(file);
// The browser has finished reading the file, we can now do something with it...
reader.onload = function(e) {
// The browser has finished reading the file, we can now do something with it...
var fileContent = e.target.result;
// Run the function to upload to the Portal Web API, passing the GUID of the newly created record and the file's contents and name as inputs
uploadFile(fileContent,fileName,entityID);
};
}
}