Client:
需要Xutils.jar
调用上传:
[java] view plain copy
String uploadHost=http://129.44.0.137:8080/AndroidUploadServer/upload.do;
RequestParams params=new RequestParams();
params.addBodyParameter(msg,imgtxt.getText().toString());
params.addBodyParameter(filePath.replace(/, ), new File(filePath));
uploadMethod(params,uploadHost);
上传方法:
[java] view plain copy
public void uploadMethod(final RequestParams params,final String uploadHost) {
http.send(HttpRequest.HttpMethod.POST, uploadHost, params,new RequestCallBackString() {
@Override
public void onStart() {
// msgTextview.setText(conn...);
}
@Override
public void onLoading(long total, long current,boolean isUploading) {
if (isUploading) {
// msgTextview.setText(upload: + current + /+ total);
} else {
// msgTextview.setText(reply: + current + /+ total);
}
}
@Override
public void onSuccess(ResponseInfoString responseInfo) {
// msgTextview.setText(reply: + responseInfo.result);
}
@Override
public void onFailure(HttpException error, String msg) {
// msgTextview.setText(error.getExceptionCode() + : + msg);
}
});
}
Server:
需要smartupload.jar猛戳下载 测试代码下载
[java] view plain copy
import com.jspsmart.upload.SmartUpload;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class UploadServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(text/html,charset=UTF-8);
SmartUpload smartUpload = new SmartUpload();
try {
smartUpload.initialize(this.getServletConfig(), request, response);
smartUpload.upload();
com.jspsmart.upload.File smartFile = smartUpload.getFiles().getFile(0);
if (!smartFile.isMissing()) {
String saveFileName = /data/ + smartFile.getFileName();
smartFile.saveAs(saveFileName, smartUpload.SAVE_PHYSICAL);
response.getWriter().print(ok: + saveFileName + , msg: + smartUpload.getRequest().getParameter(msg));
} else {
response.getWriter().print(missing...);
}
} catch (Exception e) {
response.getWriter().print(e);
}
}
}
您好,尝试太多只会暂时锁定机器,即一段时间无法解锁如果您的机器处在usb调试打开的情况下,您可以通过在开机状况下用数据线连接电脑,在电脑上打开刷机精灵等软件利用里面的去除开机密码的工具解决这个问题如果您的机器没有打开USB调试,可以通过升级官方固件来重新恢复系统感谢您对酷比魔方的支持!
加巍 tt6261130
标签:xtu