hnrch02 / multer-ftp

FTP storage engine for multer
MIT License
7 stars 3 forks source link

Error: Prohibited file name #3

Open estellederrien opened 4 years ago

estellederrien commented 4 years ago

Hello Heinrich Fenkart, how are you doing ?

I'm using https://github.com/hnrch02/multer-ftp

I am trying to upload multiples file to an infinity free FTP

This is my code :

   var FTPStorage = require('multer-ftp')

    var  storage = new FTPStorage({
        basepath: '/htdocs/files',
        ftp: {
            host: "ftpupload.net",
            user: "epiz_xxxx",
            password: "xxxxxx",
            secure: false
        }
    })

    var uploadFiles = multer({ storage: storage });

  app.post("/createFiles", uploadFiles.array("file", 10), function(req, res, err) {
        if (err) {
            console.log(err);
        }
        var filenames = [];
        req.files.forEach(function(file) {
            filenames.push(file);
        });
        res.send(filenames);
    });

This is the error :

Error: Prohibited file name: \htdocs\files\f2ad7d0610de98228039ad97b68f0429.jpg

For information, when I save the multiples files on the node server, it works :

  var storageFiles = multer.diskStorage({
        destination: function(req, file, cb) {
            cb(null, "./uploads/files");
        },
        filename: function(req, file, cb) {
            let ext = file.originalname.substring(file.originalname.lastIndexOf("."), file.originalname.length);
            cb(null, file.originalname + "-" + Date.now() + ext);
        }
    });