Skip to content
This repository
Browse code

WIP: Saving

  • Loading branch information...
commit 1aaa0b3791d577171bec6b928e4434b5bf02cb82 1 parent 23517bf
Fabian Heredia Montiel authored December 12, 2012
2  server/.gitignore
... ...
@@ -1 +1,3 @@
1 1
 node_modules/
  2
+uploads/
  3
+log.txt
5  server/app.js
... ...
@@ -1,3 +1,4 @@
  1
+var fs = require("fs");
1 2
 var express = require("express");
2 3
 var app = express();
3 4
 
@@ -7,7 +8,7 @@ app.set('view engine', 'jade')
7 8
 
8 9
 var saveReport = function(report){
9 10
 	// Saves the report
10  
-	fs.appendFile('log.txt', report, function(err){
  11
+	fs.appendFile('log.txt', JSON.stringify(report), function(err){
11 12
 		console.log(err);
12 13
 	});
13 14
 	return 0;
@@ -18,7 +19,7 @@ app.get('/', function(req, res){
18 19
 })
19 20
 
20 21
 // POST Datos
21  
-app.get('/newreport', function(req, res){
  22
+app.post('/newreport', function(req, res){
22 23
 	try {
23 24
 		var report = {
24 25
 			image: req.files.image,
7  server/views/index.jade
... ...
@@ -1,6 +1,9 @@
1 1
 html
2 2
   body
3 3
     h1 Hello
4  
-    form(method='post',action='/newreport')
5  
-      input(type='file')
  4
+    form(method='post', action='/newreport', enctype="multipart/form-data")
  5
+      input(name='image', type='file')
  6
+      input(name='location', type='hidden')
  7
+      input(name='time', type='hidden')
  8
+      input(name='type', type='hidden')
6 9
       input(type='submit') Subir

0 notes on commit 1aaa0b3

Please sign in to comment.
Something went wrong with that request. Please try again.