hi all, please help me out i am not getting any idea how to upload multiple photos in a single http connection.
i am able to apload single photo in single connection,
but my application needs to upload all photos ince the connection is made to server.
so please give me any idea as well as some code snippet for this.
this is the code i am using for upload a single photo to erver. but i need application for upload multiple photos in a single connection.
//client side code
public StringBuffer buildHTTPConnection(byte[] byteImage, String ImageName,String stringImage ) {
HttpConnection hc = null;
OutputStream out = null;
StringBuffer b=null;
try {
String url = new String("http://www.retailperformancemonitor.com/disconnected-client/ImageServlet?ImageUrl=" + ImageName);
// Obtain an HTTPConnection
hc = (HttpConnection) Connector.open(url);
// Modifying the headers of the request
hc.setRequestMethod(HttpConnection.POST);
// Obtain the output stream for the HttpConnection
out = hc.openOutputStream();
out.write(stringImage.getBytes());
int ch;
b = new StringBuffer();
InputStream is = hc.openDataInputStream();
while ((ch = is.read()) != -1) {
b.append((char) ch);
}
} catch (IOException ioe) {
StringItem stringItem = new StringItem(null, ioe.toString());
} finally {
try {
if (out != null)
out.close();
if (hc != null)
hc.close();
} catch (IOException ioe) {
}
}
return b;
}

Reply With Quote

