Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.post("/api/submit", urlencodedParser, (req, res) => {
- if (req.url == "/api/submit") {
- var form = new formidable.IncomingForm();
- form.parse(req, function(err, fields, files) {
- mv(files.fileUpload.path, "./uploads/" + files.fileUpload.name, function(
- err
- ) {
- if (err) console.log("Error while saving the file.");
- console.log("File succesfully saved.");
- });
- });
- }
- var post = {
- firstName: req.body.firstName,
- lastName: req.body.lastName,
- comment: req.body.comment,
- email: req.body.email,
- mastering: req.body.mastering,
- orderDate: req.body.orderDate,
- optCd: "",
- optVinyl: "",
- optItunes: "",
- optIsrc: "",
- fileName: req.body.fileUpload
- };
- req.body.optCd === "on" ? (post.optCd = "1") : (post.optCd = "0");
- req.body.optVinyl === "on" ? (post.optVinyl = "1") : (post.optVinyl = "0");
- req.body.optItunes === "on" ? (post.optItunes = "1") : (post.optItunes = "0");
- req.body.optIsrc === "on" ? (post.optIsrc = "1") : (post.optIsrc = "0");
- con.query("INSERT INTO orders SET?", post, function(err, result) {
- if (err) throw err;
- console.log("1 record inserted");
- });
- });
Add Comment
Please, Sign In to add comment