javascriptnode.jsexpresssails.js

Sails.js - file upload


I am working on a Sails.js project at the moment and I would like to upload a file to the server and save the link to that file in my database.

For example, when I click add FILE, it should allow me to select a file from my computer and when I click submit, it should upload the file to the URL that I point ( create the folder if it does not exist).

Can this be accomplished with Sails.js? If yes, how?

Thank you!


Solution

  • This will get you most of the way there: https://github.com/balderdashy/sails/issues/27

    You can use https://github.com/aconbere/node-file-utils to create directories, etc. Install it with

    npm install file
    

    Require file in the module having code similar to that in .../sails/issue/27.