Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 869395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:17:55+00:00 2026-05-15T10:17:55+00:00

I am creating an application in VC++ using win32,wininet to upload an image to

  • 0

I am creating an application in VC++ using win32,wininet to upload an image to Flickr.I am able to get Frob,Token correctly but when I try to upload the image I am getting error Post size too large.

Headers are created as follows

 wstring wstrAddHeaders = L"Content-Type: multipart/form-data;boundary=ABCD\r\n";
    wstrAddHeaders         += L"Host: api.flickr.com\r\n";
    wchar_t tempStr[MAX_PATH];
    wsprintf(L"Content-Length: %ld\r\n",szTotalSize);
    wstrAddHeaders         += tmpStr;
    wstrAddHeaders  +=L"\r\n";
HINTERNET hSession = InternetConnect(hInternet, L"www.flickr.com", INTERNET_DEFAULT_HTTP_PORT, NULL,NULL, INTERNET_SERVICE_HTTP, 0, 0);             
    if(hSession==NULL)
    {
        dwErr = GetLastError();
        return;
    }

Content of Post request are created as follows:

wstring wstrBoundry = L"--ABCD\r\n";

wstring wstrContent =wstrBoundry;
wstrContent +=L"Content-Disposition: form-data; name=\"api_key\"\r\n\r\n";
wstrContent +=wstrAPIKey.c_str() ;
wstrContent += L"\r\n";

wstrContent +=wstrBoundry;
wstrContent +=L"Content-Disposition: form-data; name=\"auth_token\"\r\n\r\n";
wstrContent +=m_wstrToken.c_str();
wstrContent += L"\r\n";

wstrContent +=wstrBoundry;
wstrContent +=L"Content-Disposition: form-data; name=\"api_sig\"\r\n\r\n";
wstrContent +=wstrSig;
wstrContent += L"\r\n";

wstrContent +=wstrBoundry;
wstrContent +=L"Content-Disposition: form-data; name=\"photo\"; filename=\"C:\\test.jpg\"";
wstrContent +=L"\r\n";
wstrContent +=L"Content-Type: image/jpeg\r\n\r\n";

wstring wstrFilePath(L"C:\\test.jpg");
CAtlFile file;

HRESULT hr = S_OK;
hr = file.Create(wstrFilePath.c_str(),GENERIC_READ,FILE_SHARE_READ,OPEN_EXISTING);
if(FAILED(hr))
{
    return;
}

ULONGLONG nLen;
hr = file.GetSize(nLen);

if (nLen > (DWORD)-1)
{
     return ;
}
char * fileBuf = new char[nLen];
file.Read(fileBuf,nLen);

wstring wstrLastLine(L"\r\n--ABCD--\r\n");

size_t szTotalSize =  sizeof(wchar_t) * (wstrContent.length()) +sizeof(wchar_t) * (wstrLastLine.length()) + nLen;
unsigned  char *buffer = (unsigned char *)malloc(szTotalSize);
memset(buffer,0,szTotalSize);


memcpy(buffer,wstrContent.c_str(),wstrContent.length() * sizeof(wchar_t));
memcpy(buffer+wstrContent.length() * sizeof(wchar_t),fileBuf,nLen);
memcpy(buffer+wstrContent.length() * sizeof(wchar_t)+nLen,wstrLastLine.c_str(),wstrLastLine.length() * sizeof(wchar_t));

hRequest =  HttpOpenRequest(hSession, L"POST", L"/services/upload/", L"HTTP/1.1", NULL, NULL, 0, NULL);
if(hRequest)
{
    bRet = HttpAddRequestHeaders(hRequest,wstrAddHeaders.c_str(),wstrAddHeaders.length(),HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
    if(bRet)
    {
        bRet  = HttpSendRequest(hRequest,NULL,0,(void *)buffer,szTotalSize);
        if(bRet)
        {
            while(true)         
                {   
                    char buffer[1024]={0};
                    DWORD read=0;
                    BOOL r = InternetReadFile(hRequest,buffer,1024,&read);
                    if(read !=0) 
                    {
                        wstring strUploadXML =buffer;
                        break;
                    }
                }
        }

    }

I am not pretty sure the way I am adding image data to the string and posting the request.
Do I need to convert image data into Unicode?
Any suggestions , if someone can find what I am doing wrong that would be very helpful to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:17:56+00:00Added an answer on May 15, 2026 at 10:17 am

    Actually we cannot send Post content as unicode.
    We can use headers as unicode in Wininet APIs .

    Once we read the image data in char * buffer , we can add that buffer into post content string and then add the last line of content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an application using Core Data. But When I run my app
In my WPF application, I host Win32 content using HwndHost. However, creating a HwndHost
I'm creating a Win32 GUI application using Code::Blocks and MinGW. I am using this
I'm creating an application using fabric.js , and experiencing really strange behavior. I'm adding
I am creating an application using AppleScript and I want to display a list
I'm creating an application using the ASP.NET MVC 1 framework in C#, where I
Im creating application in java using XML. XML- <?xml version=1.0 encoding=UTF-8?> <songlist id=slist> <song
I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
I'm creating a web application using spring mvc. I have started to incorporate the
I'm creating a database application using ASP.NET and I want to make a Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.