Permalink
Browse files

server: tell user if no file received

  • Loading branch information...
1 parent d4d40db commit 7c2fba52ec4cfede2be78308a11a794f7d0fd078 @astro astro committed Jan 15, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 server.js
View
@@ -27,7 +27,7 @@ function app(app) {
filename: part.filename,
mime: part.mime
} });
- var out = files.addFile({ name: part.filename,
+ out = files.addFile({ name: part.filename,
type: part.mime
});
var received = 0;
@@ -56,14 +56,19 @@ function app(app) {
form.parse(req, function(err, fields, files) { if (!error) error = err; });
req.on('end', function() {
+ if (!out && !error)
+ error = new Error('No file received');
+
if (error) {
+ /* Error */
console.error(error.stack);
res.writeHead(400, HTML_HEADERS);
res.write(template.htmlHead);
res.write(template.error(error || new Error('No file received')));
res.write(template.htmlFoot);
res.end();
} else {
+ /* Success */
res.writeHead(200, HTML_HEADERS);
res.write(template.htmlHead);
res.write(template.thanks);

0 comments on commit 7c2fba5

Please sign in to comment.