網路筆記 File Upload on PHP Server in Android



http://sunil-android.blogspot.tw/2013/09/file-upload-on-php-server-in-android.html

http://www.webtech.tw/info.php?tid=24



For this using multipart boundary. So here question is arises what is multipart boundary and why use it?

The Content-Type field for multipart entities requires one parameter, "boundary", which is used to specify the encapsulation boundary. The encapsulation boundary is defined as a line consisting entirely of two hyphen characters ("-", decimal code 45) followed by the boundary parameter value from the Content-Type header field.

Thus, a typical multipart Content-Type header field might look like this:

Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p

This indicates that the entity consists of several parts, each itself with a structure that is syntactically identical to an RFC 822 message, except that the header area might be completely empty, and that the parts are each preceded by the line --gc0p4Jq0M2Yt08jU534c0p.
Things to Note:
The encapsulation boundary must occur at the beginning of a line, i.e., following a CRLF (Carriage Return-Line Feed)
The boundary must be followed immediately either by another CRLF and the header fields for the next part, or by two CRLFs, in which case there are no header fields for the next part (and it is therefore assumed to be of Content-Type text/plain).
Encapsulation boundaries must not appear within the encapsulations, and must be no longer than 70 characters, not counting the two leading hyphens.

The encapsulation boundary following the last body part is a distinguished delimiter that indicates that no further body parts will follow. Such a delimiter is identical to the previous delimiters, with the addition of two more hyphens at the end of the line. More Details Here.

Here first I am using the code for getting the image from the gallery and set on image-view. And the set image path of the gallery on textview and send to this path for upload the image.

Lets start the code:

http://sunil-android.blogspot.tw/2013/09/file-upload-on-php-server-in-android.html

留言

這個網誌中的熱門文章

LA流浪記

杜拜