Thursday, February 20, 2014

android how to upload images to the server


android how to upload images to the server? ?<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
http, through DataOutputStream output stream byte [] array write pictures ...
Many resources upload pictures of demo
Reply:
There are several ways to die
1 Use HttpClient to upload, Enity which can contain file object
2 images can be compiled into Base64 string sent to the server (as a suitable picture smaller)
Reply:
reference to the second floor kechanghe0705 reply:
There are several ways to die
1 Use HttpClient to upload, Enity which can contain file object
2 images can be compiled into Base64 string sent to the server (as a suitable picture smaller)

Well you have sent me the next example. . E-mail: 2688759@qq.com
Reply:
cited a floor tiewantn reply:
http, through DataOutputStream output stream byte [] array write pictures ...
Many resources upload pictures demo

Well you have sent me the next example. . E-mail: 2688759@qq.com
Reply:
reference to the second floor kechanghe0705 reply:
There are several ways to die
1 Use HttpClient to upload, Enity which can contain file object
2 images can be compiled into Base64 string sent to the server (as a suitable picture smaller)


But I was in the picture when converted to base64 encode a problem
Reply:

Can be converted to binary and then spread to the database can also be uploaded via ftp,
Here is transformed into a binary stream,

/ **
* Photo transfer byte binary
* @ Param imagepath need to turn byte photographs path
* @ Return has turned into a byte
* @ Throws Exception
* /
public static byte [] readStream (String imagepath) throws Exception {
FileInputStream fs = new FileInputStream (imagepath);
ByteArrayOutputStream outStream = new ByteArrayOutputStream ();
byte [] buffer = new byte [1024];
int len ​​= 0;
while (-1! = (len = fs.read (buffer))) {
outStream.write (buffer, 0, len);
}
outStream.close ();
fs.close ();
return outStream.toByteArray ();
}
Reply:
reference to the 6th floor jianglu888 reply:
can be converted to binary and then spread to the database can also be uploaded via ftp,
Here is transformed into a binary stream,

/ **
* Photo transfer byte binary
* @ Param imagepath need to turn byte photographs path
* @ Return has turned into a byte
* @ Throws Exception
* /
public static byte [] readStream (String imagepath) throws Exception {
FileInputStream fs = new FileInputStream (imagepath);
ByteArrayOutputStream outStream = new ByteArrayOutputStream ();
byte [] buffer = new byte [1024];
int len ​​= 0;
while (-1! = (len = fs.read (buffer))) {
outStream.write (buffer, 0, len);
}
outStream.close ();
fs.close ();
return outStream.toByteArray ();
}

Is not the first picture in the client and then converted to a binary stream binary stream as a parameter to the server to the server for conversion to a picture?
Reply:
reference to the second floor kechanghe0705 reply:
There are several ways to die
1 Use HttpClient to upload, Enity which can contain file object
2 images can be compiled into Base64 string sent to the server (as a suitable picture smaller)


The server how to write ah?
Reply:
The reply was deleted administrator at 2013-05-25 10:53:51

Reply:
This is what,,,, the landlord did not understand

Reply:
reference to the 10th floor jianglu888 reply:
is mean,,,, the landlord did not understand


Understand. . .
Reply:
http://www.cnblogs.com/gzggyy/archive/2011 / 08/02/2125237.html

No comments:

Post a Comment