0
Ich möchte Bilder base64 in db (mongodb) speichern, weiß aber nicht, wie man die Anfrage in node.js bekommt.Formulardaten auf node.js hochladen
Das ist mein cilent Seite Code
$('.imageUp').change(function(){
upload(new FormData(this))
})
function upload(formData){
$.ajax({
url: '/upload_img',
type: 'POST',
data: formData,
processData: false
})
}
Was soll ich dann in Knoten tun?
router.post('/upload_img', function(req, res, next) {
// what to do here? how to get the post file? I'm going to save it to mongodb
});
ich sein weiß vielleicht nicht Ihr Konzept Frage, aber ich ziehe es in Upload-Dateien mit iframe erstellen Iframe in Runtime Erstellen Sie Formular mit seinen Attributen in diesem Rumpf des Iframe mit ('enctype', 'multipart/form-data') – Marwan
Nicht die Lösung für Ihre Frage 'FormData()' nimmt eine optionale ' form 'Element als sein Argument, nicht ein' Input 'Element. Sie sollten wahrscheinlich 'new FormData()' und 'formData.append()' verwenden. – JLRishe
@JLRishe Ich bekomme Sie nicht –