Is it something like this?
<html>
<head>
<title>Notes</title>
<p>Add Notes</p>
<input type="text" id="titleid" placeholder="Title:" style="margin-left:10px; margin-bottom:10px; width:60%"/>
<div >
<textarea name="textarea" placeholder="Description" style="margin-left:10px; margin-bottom:10px; width:60%" cols="40" rows="5" id="descriptid"></textarea>
<div class="header">
<div class="contactheader">
<div align="left" style="margin-left:0px;margin-bottom:0px;margin-top:15px "> <label style=" font-size:14px;">Select Files to Upload</label></div>
<input type="file" id="file" name="files[]" multiple="true" value="" style="float:left;margin-left:0px;margin-top:0px; width: 380px" />
<button class="button" onclick="save()">Save</button>
</script>
<script type="text/javascript" language="javascript" >
var id = opener.parent.Xrm.Page.data.entity.getId();
var nam = opener.parent.Xrm.Page.data.entity.getEntityName();
function _arrayBufferToBase64(buffer) {
var binary = '';
var bytes = new Uint8Array(buffer);
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
function createNote(title, description, docBody, fName, mType) {
var entity = {};
if (docBody != null & fName != null & mType != null) {
entity.DocumentBody = docBody;
entity.FileName = fName;
entity.MimeType = mType;
}
entity.Subject = title;
entity.NoteText = description;
entity.ObjectId = {
Id: id,
LogicalName: nam
};
SDK.REST.createRecord(
entity,
"Annotation",
function (result) {
var newEntityId = result.AnnotationId;
opener.RetrieveAnnotations(null);
window.close();
},
function (error) {
Xrm.Utility.alertDialog(error.message, null);
}
);
}
function save() {
var file = document.getElementById("file").files[0];
var subject = document.getElementById("titleid").value;
var desc = document.getElementById("descriptid").value;
if (file) {
var reader = new FileReader();
reader.onload = function (evt) {
var str = _arrayBufferToBase64(reader.result);
createNote(subject, desc, str, file.name, file.type);
}
reader.readAsArrayBuffer(file);
}
else {
createNote(subject, desc, null, null, null);
}
}
</script>
</body>
</html>