manuelkiessling/nodebeginner.org

Still doesn't work on windows for 'show image right after uploading'

Closed this issue · 1 comments

The latest zipped code doesn't work on windows for file renaming. So I resort to file copying instead.

Dig in for a while. Come up with one solution. See below.

In the upload request handler, use code below for file copying.

fs.createReadStream(files.upload.path).
pipe(fs.createWriteStream('/tmp/test.jpg').
on('close', function(){
response.writeHead(200, {"Content-Type": "text/html"});
response.write("received image:
");
response.write("");
response.end();
}));

The above code worked for me on windows. But still needed to specify the paths with ./ instead of /