向服务器端发送照片,想到类似QQ上传照片,好像都是一张一张上传的。比如,上传好几张照片,突然没网了,已经上传的照片应该提示上传成功吧。
Android客户端向服务器端上传照片,http post方法,问了要上传的参数,之前做过类似的,好像是拼一条URL就可以了。现在,把需要的参数拼起来,报500错误。
没有头绪,烦躁的一米。
后来同事提醒,post方法参数不能直接拼接。
使用POST请求时,POST的参数不是放在URL字符串里,而是放在HTTP请求数据中,所以我们需要对POST的参数进行封装。
上传图片浏览器审查元素看到的结果:
-
Request URL:http://221.6.13.210:18086/WSFOR_HI_LINK/uploadPic.do?method=uploadPic
-
Request Method:POST
-
Status Code:200 OK
- Request Headersview source
-
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
-
Accept-Encoding:gzip,deflate,sdch
-
Accept-Language:zh-CN,zh;q=0.8,en;q=0.6
-
Cache-Control:max-age=0
-
Connection:keep-alive
-
Content-Length:40971
-
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryjnAr2WfTyfAR4Fqj
-
Cookie:JSESSIONID=A244DD965B41779D4B3ACD7C4C0CE7CC
-
Host:221.6.13.210:18086
-
Origin:http://221.6.13.210:18086
-
Referer:http://221.6.13.210:18086/WSFOR_HI_LINK/
-
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
-
- Query String Parametersview sourceview URL encoded
-
method:uploadPic
-
- Request Payload
- ------WebKitFormBoundaryjnAr2WfTyfAR4Fqj Content-Disposition: form-data; name="troubleNo" 00005006144623154627434 ------WebKitFormBoundaryjnAr2WfTyfAR4Fqj Content-Disposition: form-data; name="imgFile"; filename="01300000145751121643454369622.jpg" Content-Type: image/jpeg ------WebKitFormBoundaryjnAr2WfTyfAR4Fqj--
- Response Headersview source
-
Content-Length:0
-
Date:Mon, 24 Mar 2014 04:59:56 GMT
-
Server:Apache-Coyote/1.1
-