<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#getbtn").click(function () {
GetRequest();
});
});
function GetRequest() {
var ibObj = {
RequestorName: $("#txtRequestor").val(),
RequestorEmail: $("#txtRequestorEmail").val(),
RequestTitle: $("#txtTitle").val(),
Description: $("#txtDesc").val(),
RequestType: $("#ddlRequestType").val(),
RequestPriority: $("#ddlReqPriorty").val(),
ExpCompleteDate: $("#txtReqCompletionDate").val(),
GISTicketNo: $("#txtgis").val(),
FileName:fileName,
FileByteArray: fileByteArray
}
var obj = JSON.stringify(ibObj);
$.ajax({
url: "api/ibase/IbaseEntity/",
type: "POST",
data: obj,
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
$("#ibase").text(data);
},
error: function (error) {
alert(JSON.stringify(error));
}
});
}
var fileByteArray = []; var fileName;
function getFilebytes() {
var file = document.getElementById("fileUpload").files[0];
fileName = file.name;
let fileReader = new FileReader();
fileReader.readAsArrayBuffer(file);
fileReader.onload = function (ev) {
const array = new Uint8Array(ev.target.result);
for (let i = 0; i < array.length; i++) {
fileByteArray.push(array[i]);
}
console.log(fileByteArray); // here it is
}
}
</script>
<style>
table {
height: 200px;
}
</style>
</head>
<body>
<div id="ibase" style="color:green"></div><br />
<div>
<table>
<tr>
<td>Request Title:</td>
<td><input id="txtTitle" type="text" /></td>
</tr>
<tr>
<td>Request Type:</td>
<td>
<select name="ddlRequestType" id="ddlRequestType" class="form-control">
<option value="--Select--">--Select--</option>
<option value="Request New Field">Request New Field</option>
<option value="Add Assemblies">Add Assemblies</option>
<option value="Data Cleanup">Data Cleanup</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td>Request Priority:</td>
<td>
<select name="ddlReqPriorty" id="ddlReqPriorty" class="form-control">
<option value="--Select--">--Select--</option>
<option value="P1:Critical">P1:Critical</option>
<option value="P2:High">P2:High</option>
<option value="P3:Medium">P3:Medium</option>
<option value="P4:Low">P4:Low</option>
</select>
</td>
</tr>
<tr>
<td>Expected Completion Date:</td>
<td><input id="txtReqCompletionDate" type="text" value="2021-01-27" /></td>
</tr>
<tr>
<td>Description:</td>
<td><input id="txtDesc" type="text" value="desc" /></td>
</tr>
<tr>
<td>GIS Ticket No:</td>
<td><input id="txtgis" type="text" value="12345" /></td>
</tr>
<tr>
<td>RequestorName</td>
<td><input id="txtRequestor" type="text" value="Navneet Sharma --CNTR" /></td>
</tr>
<tr>
<td>RequestorEmail</td>
<td><input id="txtRequestorEmail" typetext value="navneet_sharma@contractor.amat.com" /></td>
</tr>
<tr>
<td>File Upload</td>
<td><input id="fileUpload" type="file" onchange="getFilebytes()" /></td>
</tr>
<tr>
<td colspan="2"><br /><input id="getbtn" type="button" value="Save" /></td>
</tr>
</table>
<br />
</div>
</body>
</html>