0

I'm using the latest version of node and express. I have the the following code in my jade template

.form-group
    label.btn.btn-default
        | Browse
        input.form-control(type='file', name='zipfile', id='zipefile', hidden ='')

which translates to

<div class="form-group">
  <label class="btn btn-default">Browse
    <input type="file" name="zipfile" id="zipefile" hidden="" class="form-control"/>
  </label>
</div>

When I log out the file name

exports.postTranslate = (req, res) => {
    console.log("req.body",req.body);
    console.log("req.body.zipfile", req.body.zipfile)
    res.redirect('/result');
};

I get the name of the file. From here, how do I save the zip file to disk on the server?

user379468
  • 3,989
  • 10
  • 50
  • 68
  • 1
    Possible duplicate of [How to upload, display and save images using node.js and express](https://stackoverflow.com/questions/15772394/how-to-upload-display-and-save-images-using-node-js-and-express) (Note that it doesn't matter that it's a zip file versus an image.) – Jordan Kasper Aug 01 '17 at 14:14
  • https://stackoverflow.com/a/34577106/5225363 – Gandalf the White Aug 01 '17 at 14:16
  • Check my answer there. Don't go on question's heading, I have explained everything with code and all. It'll be easy. – Gandalf the White Aug 01 '17 at 14:16
  • So the file node has not children ... in other words when I log req.body.zipfile I just get a name, there is not filepath, associated with it ( like the linked example – user379468 Aug 01 '17 at 14:17
  • Ok, it was the csrf that was messed up, has to set it using lusca – user379468 Aug 01 '17 at 15:22

0 Answers0