Java的上传Applet的请求 [英] Java Upload Applet Request

查看:202
本文介绍了Java的上传Applet的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可有人请告诉我/链接一个简单的多部分表单数据,HTTP POST文件上传脚本,我可以转换成一个小程序?寻找有人谁去容易对我来说,我一直在这个进球后了一个多月,现在,只需要这个。我很新的Java和已经对我的方式几个小的胜利整理这个项目,但我绝对需要这方面的帮助。

Can someone please show me/link a simple multipart form data, http post file upload script I can convert to an applet? Looking for someone that who will go easy on me, I've been after this goal for over a month now and just need this. I'm very new to java and have had several small victories on my way to finishing this project but I absolutely need help with this.

我已经得到了一些签名的脚本工作,所以我做我自己的很多,但我需要一个在这里不好。我只是很困惑。

I've already got a few signed scripts working, so I've done a lot on my own, but I need one here bad. I'm just so confused.

推荐答案

从你的小程序做一个HTTP POST的最简单的方法是使用的 Apache的HTTP客户端。你需要的jar文件添加到您的小程序的类路径 。一个简单的例子:

The easiest approach to do an http post from your applet is to use Apache HTTP Client. You'll need to add the jar file to your applet's classpath. A simple example:

HttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://example.com/test");
MultipartEntity entity = new MultipartEntity();
entity.addPart("file1", new FileBody(new File("filetoUpload.jpg"), "application/jpg"));
post.setEntity(entity);
client.execute(post)
client.getConnectionManager().shutdown();

如果由于某种原因,你不能使用HTTP客户端仍然可以做到与的java.net.URL 但它是一个复杂多了:

If for some reason you cannot use HTTP Client you can still do it with java.net.URL but it's a lot more complicated:

<一个href=\"http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests#2793153\">How使用java.net.URLConnection中的火灾和处理HTTP请求?

这篇关于Java的上传Applet的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆