An error occured on upload
An error occured on upload
I have the same issue as this post below. The file is saved to the database and all but I keep hitting an error when trying to return the right Json to editor.
https://datatables.net/forums/discussion/comment/225563/#Comment_225563
This is my return. I am using c# and I have tried using return Json(), returning it as a string, and JsonSerializer:
{
"files": {
"fileId": 1
}
}
Answers
Hi,
Have you taken a look at the Ajax request in the browser's network inspector? That might give a clue as to what is going wrong.
Can you give me a link to the page so I can take a look? You can PM it to me if you don't want to make it public
.
Allan
Hey Allan, unfortunately I can't. The application is not external. I have change the response json multiple times. Currently, this is what I have:
{
"files": {
"file": {
"fileId": 12,
"fileName": "CallEndpointwAuthHeader.PNG",
"webPath": "/ProjectInfo/Download/630"
}
}
}
My editor javascript code for the upload looks like this:
The documentation is pretty vague on this particular topic. Can you help me figure this out?
By the way, I am not saving the file to the file system. I am using MemoryStream to save it directly to the database. Do I need to save it to the file system for this to work properly?
The response should look something like this:
The documentation for it is available here.
The key part is the
upload.id
property, which Editor will look for to know what the primary key identifier for the file is. That is currently missing from your response. You also need to nest the file information in an object with the primary key's value - so your response might look something like:Allan
Hey Allan, the information you've given me has been extremely helpful and I am able to make the upload work, just not in a way that would be useful. I think the way I think it should work is not the way it is designed, so I will have to build my own file upload process. What I expect is:
This workflow doesn't seem possible with Editor in its current form. Would you agree? Or am I missing something?