Answer the question
In order to leave comments, you need to log in
How to submit form data along with files?
Hello. I ran into a problem that I can’t solve, maybe you can help) In general, you need to send data and a picture from the form, the picture is sent, but I can’t get data with input type = text.
client
<form class="add-mult-form" ng-submit="addMult(multName)">
<div>
<label for="multName">Название:</label>
<input type="text" id="multName" ng-model="multName" required>
</div>
<div>
<label for="multImg">Картинка:</label>
<input type="file" id="multImg" nv-file-select uploader="uploader" required>
</div>
<div>
<input type="submit" value="Добавить">
</div>
</form>
$scope.uploader = new FileUploader({
url: '/add_mult',
method: 'POST'
});
$scope.addMult = function(multName) {
$scope.uploader.formData.push({multName: multName});
$scope.uploader.uploadAll();
};
app.post('/add_mult', [multer({ dest: '../src/client/image/mult/'}), function(req, res) {
console.log(req.body.multName);
res.end();
}]);
Answer the question
In order to leave comments, you need to log in
I use something like this - maybe it will simplify your task a little.
Check if you have everything according to the documentation How to update FileItem options before uploading is done.
I tried all kinds of apploaders for AnguarJS - I found, in my opinion, the most thoughtful and convenient one.
https://github.com/danialfarid/ng-file-upload
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question