×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    1

    uploading image to Apache web server

    I'm trying to uploaded an image to an Apache using multipart/form-data. I can upload text just fine.

    But with the image, I get a "chunked encoding transmission forbidden" and error 400, bad request.

    I've used the examples from whatever Nokia docs that I could find, but nothing works. I'm pretty sure my request is properly formatted as a multipart/form-data request.

    Has anyone done this?

    Any help or advice on how to upload an image to an apache web server from the phone?

    Thanks in advance!

  2. #2
    Registered User
    Join Date
    Apr 2005
    Posts
    11
    hi,

    how did u build the multipart data request..

    I am sending image binary data in Post body, & using content-type as image/jpeg.

    only partial image is sent using the code below.

    Below is the code on the phone:

    void CIapAppView::PublishImageL()
    {
    _LIT(KAttachmentFileName, "Image.jpg");

    //open image from images folder
    TFileName path = PathInfo::PhoneMemoryRootPath(); //Default
    path.Append( PathInfo::ImagesPath() );
    path.Append(KAttachmentFileName);

    TInt err=0;
    TRAP(err, AddToStatusWindowL(path));
    if(err)
    Panic(EIapView);


    RFs fs;
    User::LeaveIfError(fs.Connect());

    RFile infile;
    TInt val=infile.Open(fs,path,EFileShareExclusive|EFileRead);
    if(val==KErrNone)
    {
    TInt file_size;
    infile.Size(file_size);

    HBufC8* bufImageData;
    bufImageData = HBufC8::NewL(file_size);

    if(bufImageData)
    {
    TBuf8<256> data8;
    while(ETrue)
    {
    if(infile.Read(data8)!=KErrNone)
    {
    TRAP(err, AddToStatusWindowL(_L("Error: reading file")));
    if(err)
    Panic(EIapView);

    infile.Close();
    fs.Close();
    return;
    }
    if(data8.Length()==0) //eof
    {
    TRAP(err, AddToStatusWindowL(_L("Success: reading file")));
    if(err)
    Panic(EIapView);

    iClient->CancelTransaction();

    //use bufImageData to send http post
    TBuf8<256> uri8;

    //external public ip
    _LIT8(url1, "http://61.246.187.164/Push2Publish/Image?imageName=myimage&identityID=11");

    //internal public ip
    //_LIT8(url1, "http://192.168.102.11/Push2Publish/Image?imageName=myimage&identityID=11");

    //nitins ip
    //_LIT8(url1, "http://192.168.5.67:8080/Push2Publish/Image?imageName=myimage&identityID=11");

    uri8.Append(url1);

    TPtr8 ptr_bufImageData=bufImageData->Des();
    iClient->IssueHTTPPostL(uri8, _L8("image/jpeg"), ptr_bufImageData);


    break;
    }

    TPtr8 ptr_bufImageData=bufImageData->Des();
    ptr_bufImageData.Append(data8);

    }


    }
    else
    {
    TRAP(err, AddToStatusWindowL(_L("Error: Allocating HBuf")));
    if(err)
    Panic(EIapView);
    }

    }
    infile.Close();
    fs.Close();
    }

    Thanks

    Nitin

Posting Permissions

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