Last active
August 29, 2015 14:04
-
-
Save aaronpk/3c44eefe91cc07f259fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Multipart</h2> | |
<form action="/upload" enctype="multipart/form-data" method="post"> | |
<input type="text" name="title"><br> | |
<input type="file" name="upload" multiple="multiple"><br> | |
<input type="submit" value="Upload"> | |
</form> | |
<hr> | |
<h2>Standard</h2> | |
<form action="/upload" method="post"> | |
<input type="text" name="title"><br> | |
<input type="file" name="upload" multiple="multiple"><br> | |
<input type="submit" value="Upload"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------WebKitFormBoundaryQA9Btta4EsAMz6ID | |
Content-Disposition: form-data; name="title" | |
title | |
------WebKitFormBoundaryQA9Btta4EsAMz6ID | |
Content-Disposition: form-data; name="upload"; filename="file.png" | |
Content-Type: image/png | |
�PNG | |
IHDR���L� | |
AiCCPICC ProfileH | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
util = require('util'); | |
http.createServer(function(req, res) { | |
if (req.url == '/upload' && req.method.toLowerCase() == 'post') { | |
var postData = ''; | |
req.on('data', function(data) { | |
postData += data; | |
}); | |
req.on('end', function(){ | |
res.writeHead(200, {'content-type': 'text/html'}); | |
res.write('<pre>received upload:\n\n'); | |
res.write(postData); | |
res.write('</pre>'); | |
res.end(); | |
}) | |
return; | |
} | |
console.log("/"); | |
// show a file upload form | |
res.writeHead(200, {'content-type': 'text/html'}); | |
res.end( | |
'<h2>Multipart</h2>' + | |
'<form action="/upload" enctype="multipart/form-data" method="post">'+ | |
'<input type="text" name="title"><br>'+ | |
'<input type="file" name="upload" multiple="multiple"><br>'+ | |
'<input type="submit" value="Upload">'+ | |
'</form>' + | |
'<hr>' + | |
'<h2>Standard</h2>' + | |
'<form action="/upload" method="post">'+ | |
'<input type="text" name="title"><br>'+ | |
'<input type="file" name="upload" multiple="multiple"><br>'+ | |
'<input type="submit" value="Upload">'+ | |
'</form>' | |
); | |
}).listen(9090); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title=title&upload=file.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment