×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    17

    Question HELP:about transfer file use http

    i need transfer a file in several parts to the server's database, (the file can be of any kind of format). I use CHTTPFormEncoder, but when i tested with a jpg file, it can't be open. the promble is every '0D' in the file is replaced with '0D 0A', how the solve this promble?
    thank you in advance.
    Last edited by nathanxyy; 2009-02-11 at 02:58.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: HELP:about transfer file use http

    CHTTPFormEncoder encodes data for a form. For transferring binary data, use HTTP POST method, and provide your raw data in your own MHTTPDataSupplier.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    17

    Re: HELP:about transfer file use http

    Quote Originally Posted by wizard_hu_ View Post
    CHTTPFormEncoder encodes data for a form. For transferring binary data, use HTTP POST method, and provide your raw data in your own MHTTPDataSupplier.
    thank you so much. I need add some field on the body, so i use CHttpformEncoder. Now I add them in the URI.

    now it looks like this "http://<server-id>/***.php?***=***&***=***&***=***&***=***&****=***", which is too long.

    It's there a better way? thanks.

  4. #4
    Regular Contributor
    Join Date
    Aug 2007
    Posts
    105

    Re: about transfer file use http

    Hi Nathan,

    I'm doing the same as you are - sending JPG Images along with more information. CHTTPFormEncoder won't do the trick, as it is only meant for text data, not for binary input like images. Encode the body yourself as Content Type

    _LIT8(KMultipartContent, "multipart/form-data; boundary=abGh4h");

    then, the image and the data should look like:

    Code:
    --abGh4h
    Content-Disposition: form-data; name="Mode"
    
    1
    --abGh4h
    Content-Disposition: file; name="Image"; filename="myImage.jpg"
    Content-Type: image/jpeg
    Content-Transfer-Encoding: binary
    
    <BINARY IMAGE DATA HERE>
    --abGh4h--
    You can of course add more form feeds. Check the W3C specification for your convenience (bottom of the page for details) and make sure your webserver is also configured correctly.

    Good luck

    Chris

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    17

    Re: about transfer file use http

    Quote Originally Posted by -chris- View Post
    Hi Nathan,

    I'm doing the same as you are - sending JPG Images along with more information. CHTTPFormEncoder won't do the trick, as it is only meant for text data, not for binary input like images. Encode the body yourself as Content Type

    _LIT8(KMultipartContent, "multipart/form-data; boundary=abGh4h");

    then, the image and the data should look like:

    Code:
    --abGh4h
    Content-Disposition: form-data; name="Mode"
    
    1
    --abGh4h
    Content-Disposition: file; name="Image"; filename="myImage.jpg"
    Content-Type: image/jpeg
    Content-Transfer-Encoding: binary
    
    <BINARY IMAGE DATA HERE>
    --abGh4h--
    You can of course add more form feeds. Check the W3C specification for your convenience (bottom of the page for details) and make sure your webserver is also configured correctly.

    Good luck

    Chris
    thank you for your advice. I use _LIT8(KContentTypeForm, "application/x-www-form-urlencoded\0") and MHTTPDataSupplier
    and it works well for jpg, gif, txt... (I need to transfer those file without getting their type.)

    thanks.

Similar Threads

  1. Error with makesis.exe and creating the .pkg file
    By gramya87 in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-10-10, 13:53
  2. Help needed with a 3gp file...
    By joedoe_1981 in forum Streaming and Video
    Replies: 0
    Last Post: 2007-07-18, 18:58
  3. Contacts fields order??
    By timatima in forum Symbian
    Replies: 1
    Last Post: 2007-06-08, 13:51
  4. Replies: 3
    Last Post: 2006-12-20, 11:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×