Created
September 21, 2012 08:26
-
-
Save kjunichi/3760371 to your computer and use it in GitHub Desktop.
RingoJS v0.8 FileUpload sample script
This file contains hidden or 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 meta ='<meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=1.0, user-scalable=no">'; | |
var msg = ''; | |
msg = msg + "<h2>test</h2>"+req.method; | |
msg = msg + "<p>"+req.queryString + "</p>"; | |
var httpUtils = require('ringo/utils/http'); | |
// ファイルアップロードか判定する。 | |
if(httpUtils.isFileUpload(req.headers["content-type"])) { | |
var params = {}; | |
httpUtils.parseFileUpload(req,params); | |
var base64 = require('ringo/base64'); | |
msg=msg+"<img src="+"\"data:image/"+params['pics'].contentType +";base64," | |
+base64.encode(params['pics'].value)+"\">"; | |
} | |
var res={}; | |
res.status="200"; | |
res.headers={}; | |
res.headers['content-type']="text/html"; | |
res.body=["<html><head>",meta,"</head><body>",msg,"</body></html>"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment