J2MEpost方式上传文件
public void upload() {
String name = po.getName(); // file name
String str = po.getStr()+"/plugins/j2me"; // url
byte[] raw = snap.getData(); // file data
String cmd = "uploadpic";
String auth = po.getUserId();
String albumId = po.getUserId();
String type = po.getType();
String remarks = po.getDemo();
String[] props = { "cmd","auth","albumId", "public", "remarks" }; //property name
String[] values = { cmd, auth, albumId, type, remarks }; // property value
try {
String BOUNDARY = "---------7d4a6d158c9"; // separate line
String MULTIPART_FORM_DATA = "multipart/form-data";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < props.length; i++) { // send each property
sb = sb.append("--");
sb = sb.append(BOUNDARY);
sb = sb.append(""r"n");
sb = sb.append("Content-Disposition: form-data; name="""+ props[i] + """"r"n"r"n");
sb = sb.append(URLEncoder.encode(values[i],"UTF-8"));
编辑推荐:
温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)
点击加载更多评论>>