Editor: How can I use Node.js for uploading files?
Editor: How can I use Node.js for uploading files?
Hi,
I am using Node.js to build my website server end. It is confusing to me that all codes in examples are using PHP or .NET. When I include files upload in Editor, after I click "choose file..." and select a file to upload, it shows an error:
A server error occurred while uploading the file
And Chrome shows an POST error in the console panel:
POST http://localhost:3000/test 404 (Not Found)
So the ajax POST path of file upload is different from the ajax POST path of editor, which is http://localhost:3000/testajax/
.
The codes in client end are shown below:
{
label: "Upload Files:",
name: "files",
type: "uploadMany",
display: function(fileId, counter) {
return '<a href="' + editor.file('files', fileId).web_path + '">' + editor.file('files', fileId).filename + '</a>';
},
noFileText: 'No files'
}
How can I solve this problem without using PHP or .NET?
This question has an accepted answers - jump to answer
Answers
I have solved this problem. Node.js needs "multer" or other middleware to parse the form-data that contains files. And the return value should also include:
"data":[]