views:

2013

answers:

4

How can I send a picture in j2me maybe using base64 decode and the send in post form via http request

A: 
HttpConnection connection = (HttpConnection) Connector.open("http://www.myserver.com");
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("Content-Type","image/png");
OutputStream os = connection.getOutputStream();
// write your picture data to os
os.flush();

if (connection.getResponseCode() == HttpConnection.HTTP_OK)
{
Dmitry Khalatov
A: 

Yes , I'm use that to send the base64 ,putting in

// write your picture data to os

os.write (data);

where data = String with a base64 image , the problem is that i don't have a base64 library that works in java and asp in the same way.

Juancho
A: 

Have you considered using a "multipart/form-data" encoding type? If you so, then there is no need for Base64 encoding. See here and here for instructions on how to build the request.

If you still want to do the Base64 encoding, then you will be able to easily find many source implementations on the Web. If you are developing both the server and client side, you could use your own implementation on both ends.

kgiannakakis
A: 

There are plenty of coders in Base64 for Java. Apache commons has one, here is a standalone one.

Fernando Miguélez