richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

express-fileupload unable to recognize files from form using bootstrap 4 #235

Closed Plidian closed 4 years ago

Plidian commented 4 years ago

To reproduce 1) build an html page that uses an HTML form to allow upload of files e.g. <form ref='uploadForm' id='uploadForm' action='/upload_grid' method='POST' encType="multipart/form-data"><span class="tekst"><label for="user">Username: </label><input type="text" name="user"/></span> <span class="tekst"><div>Provide the file</div></span> <input type="file" name="unitlist" /> <span class="tekst"><div><input type='submit' value='Upload!' /></div></span> </form> And build a node.js server that uses express-filesupload to capture the file for processing e.g. const express = require("express"); const port=process.env.port || 3000; const app=express(); const fileUpload = require('express-fileupload'); app.use(express.urlencoded({extended: false})); app.use(express.json()); app.use(express.static(path.join(__dirname,''), { etag: false, maxAge: "365d", setHeaders: function (res, path) { if (mime.lookup(path) === 'text/html') { // For HTML, avoid long and immutable cache since it can't be busted res.setHeader('Cache-Control', 'public, max-age=0'); } } })); app.use(fileUpload()); app.post('/upload_grid', function(req, res) { if (!req.files) {return res.status(400).send('No files were uploaded. req.files was falsey');} res.redirect("upload_grid");}); app.get("/upload_grid",function(req,res){ res.render("upload_grid"); }); app.listen(port,() =>console.log(Express web server is running...on ${port})); Verify that this works. 2) Replace the HTML with a bootstrap 4 enabled form using custom forms. e.g. `

Plidian commented 4 years ago

didn't do my due diligence like I thought I had, I missed that name was missing from the input