用java.net的请进,一个关于用URL上传文件的问题.

pantech_36 2003-05-28 08:24:08
用如下代码我实现了一个表单的提交,但是我如何做到用URL来提交一个enctype="MULTIPART/FORM-DATA" 的表单呢???

String sIP = r.getString("ServerIP");
String sPort = r.getString("ServerPort");
URL url = new URL("http://"+sIP+":"+sPort+"/corp/HttpMtServlet");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.println(strusername+"&"+strpasswd+"&"+strtonum+"&"+strtext+"&"+strpresendtime+"&"+strmoid+"&"+strfromnum+"&"+strpaynum+"&"+strserviceid+"&"+strfeetype+"&"+strfeeusertype+"&"+strfee+"&"+strformat);
out.close();
...全文
51 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xqi8 2003-06-09
  • 打赏
  • 举报
回复
up
pantech_36 2003-06-09
  • 打赏
  • 举报
回复
谢谢楼上的两位

我是客户端用java自动POST,服务端我要用PHP接收的。
gongfucai 2003-06-09
  • 打赏
  • 举报
回复
你用一个的javabean SmartUpload吧,网上有下载,很方面



pantech_36 2003-05-30
  • 打赏
  • 举报
回复
其实我主要是想做一个网站后台更新程序,要将本地某个目录中的图片自动上传到服务器。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧