javascript - grunt-contrib-connect and file uploading -
i have simple grunt-contrib-connect server. exists jut local use, local access.
i'd have ability choose files file system , put them in directory in grunt project.
here's html:
<form method="post" name="upload" action="uploaded" enctype="multipart/form-data"> <input type="file" name="files" multiple accept=".jpg,.png"> <input type="submit"> </form>
here run connect:
grunt.config('connect.ui', { options: { port: 9000, protocol: 'http', hostname: 'localhost', keepalive: true, middleware: [ function themiddleware(req, res) { res.setheader('access-control-allow-origin', '*'); res.setheader('access-control-allow-methods', 'get,put,post,delete'); processrequest(req, res); } ] } });
but don't have ideas how put selected files in directory of grunt project.
i'll glead hear ideas or solutions.
thanks in advance.
it should easy using multer-middleware:
var multer = require('multer'); grunt.config('connect.ui', { options: { port: 9000, protocol: 'http', hostname: 'localhost', keepalive: true, middleware: [multer({ dest: './your-upload-folder/'})] } });
Comments
Post a Comment