Hello everyone,
I tried to bind image inside jquery datatable plugin but it is showing an error 'Not allowed to load local resource: file:///E:/myworks/Demo/Images/Img/16.png' .
I am attaching my code along with it. Please help me to get out of this issue.
- $('#dataTable').DataTable({
- ordering: true,
- searching: false,
- paging: false,
- autoWidth: true,
- processing: true,
- responsive: true,
- bSort:true,
- language: {
- "processing": "Loading..."
- },
- ajax: {
- url: "/Login/GetAllData",
- type: "POST",
- datatype: "json"
- },
- pageLength: 7,
- columns: [
- { "data": "ID", "name":"ID", "defaultContent": "<i>-</i>" },
- { "data": "Type","name":"Type", "defaultContent": "<i>-</i>" },
- { "data": "To", "name": "To", "defaultContent": "<i>-</i>" },
- {
- "data": "ImagePath", "name": "ImagePath", "defaultContent": "<i>-</i>",
- "render": function (data, type, row, meta) {
- debugger;
- return '<img src="' + data + '"height="70px" width="40px"/>';
- }
- }
- ],
- columnDefs: [
- { className: "text-center", "targets": [0, 1, 2] },
-
-
-
-
-
-
- ],
- destroy:true
- })
and my controller is given below
- try
- {
- if (busModelVM.File != null&&busModelVM.File.ContentLength>0)
- {
- var fileName = Path.GetFileName(busModelVM.File.FileName);
- var ext = Path.GetExtension(busModelVM.File.FileName);
- string name = Path.GetFileNameWithoutExtension(fileName);
- string myFile = name + ext;
- var path = Path.Combine(Server.MapPath("/Images/Img"),myFile);
- busModelVM.File.SaveAs(path);
- busModelVM.ImagePath = path;
-
-
-
-
-
-
-
- }
- var result = _class1.InsertUpdateData(_mapper.MapToBusMaster(busModelVM), conString);
-
- return JsonConvert.SerializeObject(new { Status = "OK", Records = result, Message = "Insertion sucessfull" });
- }
- catch(Exception ex)
- {
-
- return JsonConvert.SerializeObject(new { Status = "ERROR", Records = "", Message = ex });
- }
I think it is an issue in saving image path. Please help me to get out of the issue.