Created
January 13, 2011 15:46
-
-
Save cronopio/778073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.save = function(req, res){ | |
var form = new formidable.IncomingForm(), | |
campos = {}, | |
files = []; | |
// Configuro el directorio donde guardar | |
form.uploadDir = __dirname + '/../public/imgs'; | |
form.keepExtensions = true; | |
console.log(form); | |
form | |
.on('field', function(f, v){ | |
campos[f] = v; | |
console.log(v); | |
}) | |
.on('file', function(f, archivo){ | |
files.push([f, archivo]); | |
campos.imagen = path.basename(archivo.path); | |
console.log(campos.imagen); | |
}) | |
.on('end', function(){ | |
var ed = new Edicion(campos); | |
ed.save(function(){ | |
req.flash('success', 'Edicion Guardada!'); | |
res.redirect('/ediciones'); | |
}, function(){ | |
req.flash('error', 'Ocurrió un error al guardar!!'); | |
}); | |
}); | |
form.parse(req); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment