editor file upload is not working
editor file upload is not working
iloveuu
Posts: 6Questions: 1Answers: 1
I am suffering from file uploading with editor.
var _editor = new $.fn.dataTable.Editor({
ajax: {
url: url,
contentType: 'application/json',
data: function ( d ) {
return JSON.stringify( d );
}
},
table: objId,
template: template,
idSrc: 'id',
fields: [....
{label: "image", name: "images", type: "uploadMany", className: 'block', display: function ( fileId, counter ) {
return '<img src="'+editor.file( 'files', fileId ).web_path+'"/>';
}}, ...
]
});
When file uploading, error message is like below
TypeError: a is not an Object. (evaluating '"length"in a')
I am using DataTables Editor v1.6.2, DataTables 1.10.13, Buttons 1.2.3, query-3.1.1.
What's wrong??
Thanks in advance~
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I have solved this problem. The problem was me. I didn't know that it needs a server handler of file upload before submitting.
Thanks for posting back - great to hear you've got it working now.
Allan
{
"upload": {
"id": "1"
},
"files": {
"images": {
"1": {
"id": 1,
"filename": "53fa859767aa2.png",
"filesize": 95034,
"web_path": "https://t1.daumcdn.net/daumtop_chanel/op/20170315064553027.png",
"system_path": "/tmp/20170315064553027.png"
}
}
}
}
Thanks allan. but i am suffering from another problem. After ajax communication successfully, I have received json message like above (according to my server handling).
but I can't get information about uploaded file.
if editor.file('images') is called, then it returns error message "Unknown file table name: images". If editor.files() is called, then it returns empty object -> { }
display: function (fileId, counter) {
console.log(editor.files());
return '<span>' + fileId + "</span>";
}
What's the problem??
That looks like it should work okay. Any chance of a link to the page showing the issue please?
Allan
Thanks allan. I hope you confirm my application in server I maked. My temporary server address is below.
http://cunion.iptime.org:28080/myhub-admin
You can login with account like this (ID : admin, Password : pass)
then if you access to 상품관리 menu or address ( http://cunion.iptime.org:28080/myhub-admin/prod/list ), then you will see datatables grid. If you click New button, the editor including fileupload is displayed. Now, if any file is uploaded, "Uncaught file table name: images" message is displayed. The json data from the temporary server is hardcoded, so it's always same even though any file is uploaded. Please, help me.
Thanks for the link and details. however, when I attempt to login with that info the form just releases - no error message shown. But there is
?error
appended to the URL.Allan
I let you know wrong password. I edited my posting. I think you used wrong password I wrote at first. Can you try it one more??
ID : admin
Password : pass
Sorry for that~
Thanks! With that I've realised what is happening.
The Editor examples all populate the
files
option in the object that is loaded by DataTables in the first instance. However, in this case it hasfiles: null
. Then the code later attempts to extend thenull
like it would do with an array, which is wrong!If you use the non-min version of Editor you can find the following code:
And replace it with:
That I believe should resolve the issue.
Thanks for letting me know about this!
Regards,
Allan
Thanks for taking care of me, Allan. You saved my life~
It works.