multer

ENOENT: no such file or directory .?

大兔子大兔子 提交于 2019-12-30 04:22:12
问题 This is error which am getting while post data and file. I have followed 'academind' tutorial for building Restful API services, also i have been searching answer for this type of errors but nothing works for me. Am using "multer" to upload file The folder 'uploads' available in the folder but it shows ENOENT: no such file or directory, open 'D:\project\uploads\2018-01-24T07:41:21.832Zcheck.jpg'" app.js const express = require("express"); const app = express(); const morgan = require("morgan"

Node Multer unexpected field

情到浓时终转凉″ 提交于 2019-12-29 10:15:23
问题 I'm working on uploading a file to my app using the multer npm module. The multer function I have defined is to allow a single file uploaded to the file system. Everything works during run time; the issue is after I upload the file I get an error below. Any advice appreciated on where to look. Error: Unexpected field Error: Unexpected field at makeError (c:\Users\Dev\WebstormProjects\Crunch\node_modules\multer\lib\make-error.js:12:13) at wrappedFileFilter (c:\Users\Dev\WebstormProjects\Crunch

Error uploading files using Multer in NodeJs

安稳与你 提交于 2019-12-29 09:50:13
问题 I am trying to write an Express-based API for uploading files. The filename and directory path should be set dynamically. My code: var crypto = require('crypto') var express = require('express'); var fs = require('fs'); var mime = require('mime'); var mkdirp = require('mkdirp'); var multer = require('multer'); var app = express(); var path = './uploads'; var storage = multer.diskStorage({ destination: function (req, file, callback) { callback(null, path); console.log('Im in storage

Cannot app.use(multer). “requires middleware function” error

[亡魂溺海] 提交于 2019-12-28 02:02:05
问题 I'm just starting learning NodeJS and I am stuck with a problem. I would like to upload files to my server. To do so I searched and found out this module multer. Doing as the example on GitHub works: var express = require('express'); var multer = require('multer'); var upload = multer({ dest: 'uploads/' }); var app = express() app.post('/uploadImage', upload.single('image'), function(req, res) { console.log(req.file); }); On posting an image with FormData to /uploadImage the image is saved in

multipart/form-data form with no field names

烂漫一生 提交于 2019-12-25 11:53:34
问题 I have an HTML form that I was using to send information to the nodejs backend. I then tried to implement file uploads using the same form. To do that, I had to change the enctype of the form from the default value (application/x-www-form-urlencoded) to be enctype='multipart/form-data', and I had to use multer on the backend. I also had this button: <input type="button" value="Submit" onclick="submitRequest(this);"> which I had to change to: <input type="submit" value="Submit" onclick=

Express, Multer, BodyParser req.body empty array

六月ゝ 毕业季﹏ 提交于 2019-12-25 07:38:54
问题 Sorry for such a noob question, but I have a form upload images and add some text to the DB, the images are uploading fine, but the req.body object is always an empty array. HTML <form class='new-project' action='/projects' method='POST' enctype="multipart/form-data"> <input type="text" name="title" placeholder="Project Title"> <br> <textarea name="description" rows="8" cols="40" placeholder="Project description"></textarea> <br> <label for='file'>Select your image:</label> <input type='file'

Multer is not saving the file as the same name and without extension?

纵然是瞬间 提交于 2019-12-25 00:34:43
问题 I am using Multer to save files I upload through a form but I do not know why my code saves it as a weird name and without extension and I have just used the code from the documentation. server.js: const multer = require('multer'); const app = express(); var upload = multer({ dest: 'uploads/' }) app.post('/file', upload.single('filesToAttach'), function (req, res, next) { console.log(req.file); loadUserPage(req, res); }) userPage.ejs: <form action="/file" method="post" enctype="multipart/form

Filter file in using multer by file type

白昼怎懂夜的黑 提交于 2019-12-24 18:33:49
问题 I use multer module in nodejs to upload some images (only tiff and jpg format). I want filter and storage only tiff and jpg images. For now I do this: var upload = multer({ storage: storage, fileFilter: function(req, file, cb){ //--------------------------- //CHECK IF THE FILE IS IN A CORRECT FORMAT //------------------------ if((file.mimetype == "image/jpeg" || file.mimetype == "image/jpg" || file.mimetype == "image/tiff")){ //correct format return cb(null, true); } else{ //wrong format

Proper way to use connect-multiparty with express.js?

两盒软妹~` 提交于 2019-12-24 00:44:53
问题 I am trying to upload files to my server and extract them from the post request using the connect-multiparty middleware. However, when I receive the request on the server, the req.files and req.body objects are empty (not null, but node-inspector shows that they are Object s with nothing in them. Here is the code that I'm working with: server.js: var express = require( "express" ); var app = express(); var server = require( "http" ).Server( app ); var fs = require( "fs" ); var multipart =

Rename a file with multer is not working

荒凉一梦 提交于 2019-12-23 20:37:51
问题 I'm trying to rename a file using multer. I want to rename the file uploaded to a .jpg Instead of the tutorial about multer, i'm calling the method rename in my route file. The file is well uploaded but I don't get why the function rename is not working. By the way, the word 'ici' doesn't appear into my console router.post('/edit/saveEdit',multer({ rename : function(fieldname, filename, req, res) { console.log('ici'); return req.body.infoUser.id }}), function(req,res){ // console.log(req.body