---
title: "The POST and GET of Mochiweb"
author: "langzhe"
date: "2014-07-31T15:34:02Z"
tags: []
categories: ["编程语言"]
slug: "the-post-and-get-of-mochiweb"
draft: false
lastmod: "2014-07-31T15:37:01Z"
id: 2098693
url: "https://langzhe.iteye.com/blog/2098693"
---

%% The request  of POST  
113     Form = mochiweb\_request:parse\_post(Req),    

 

%%  The request of GET

113     Form = mochiweb\_request:parse\_qs(Req),    

 

%% The file  upload

 79     Form = mochiweb\_multipart:parse\_form(Req),

 80     ?DEBUG("~p:~p sss length(Form)=~p", \[?MODULE, ?LINE, length(Form)]),

 81     Jid = proplists:get\_value("jid", Form, ""),

 

 

%% download file

218 parse\_request\_get(Req, "file/get\_small\_avatar/"++Path, DocRoot) -&gt;

219     NewPath="avatar/small/"++Path++".jpg",

220     Req:serve\_file(NewPath, DocRoot);

 

 

113     Form = mochiweb\_request:parse\_post(Req),                                                                                          

114     ?DEBUG("~p:~p sss Form=~p", \[?MODULE, ?LINE, Form]),

115     Username = proplists:get\_value("username", Form, ""),

116     Password = proplists:get\_value("password", Form, ""),

117     Type = proplists:get\_value("type", Form, ""),

 

184             Req:ok({"text/html", \[], &lt;&lt;"&lt;html&gt;

185                 &lt;head&gt;&lt;meta http-equiv=\\"Content-Type\\" content=\\"text/html; charset=utf-8\\" /&gt;

186                 &lt;/head&gt;&lt;body&gt;&lt;h1&gt;APK上传&lt;/h1&gt;

187                 &lt;form enctype=\\"multipart/form-data\\" action=\\"/upload/save\_apk\\" method=\\"post\\"&gt;

188                 &lt;label for=\\"file\\"&gt;版本号&lt;/label&gt;

189                 &lt;input type=\\"input\\" name=\\"version\\" id=\\"version\\"/&gt;

190                 &lt;label for=\\"file\\"&gt;描述&lt;/label&gt;

191                 &lt;input type=\\"input\\" name=\\"desc\\" id=\\"desc\\"/&gt;

192                 &lt;label for=\\"file\\"&gt;server&lt;/label&gt;

193                 &lt;input type=\\"input\\" value='wx.com' name=\\"server\\" id=\\"version\\"/&gt;

194                 &lt;input type=\\"file\\" name=\\"file\\" id=\\"file\\"/&gt;

195                 &lt;input type=\\"submit\\" name=\\"upload\\" value=\\"Upload\\" /&gt;

196                 &lt;/form&gt;

197                 &lt;/body&gt;&lt;/html&gt;"&gt;&gt;});