Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ManuelKiessling/NodeBeginnerBook
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelkiessling committed Dec 9, 2011
2 parents b32fcae + 0e0f750 commit e7b176c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions code/application/requestHandlers.js
Expand Up @@ -31,6 +31,12 @@ function upload(response, request) {
console.log("about to parse");
form.parse(request, function(error, fields, files) {
console.log("parsing done");

/*
* Some systems [Windows] raise an error when you attempt to rename new file into one that already exists.
* This call deletes the previous .PNG image prior to renaming the new one in its place.
*/
fs.unlinkSync("/tmp/test.png"); .
fs.renameSync(files.upload.path, "/tmp/test.png");
response.writeHead(200, {"Content-Type": "text/html"});
response.write("received image:<br/>");
Expand Down

0 comments on commit e7b176c

Please sign in to comment.