PUT and InternetWriteFile
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: PUT and InternetWriteFile

  1. #1
    Join Date
    Dec 1999
    Location
    Karnataka,India
    Posts
    2

    PUT and InternetWriteFile

    I am using the WinInet API to upload a binary file to a web server. The web server doesn't have FTP service. So, I am restricted to HTTP Put.
    How do I do that using InternetWriteFile?
    When I send the PUT request and use InternetWriteFile, the file is getting created on the web server, but it is empty. I have tried both text and binary content, but in vain.
    Has anyone done this, can you give me some lead?
    -thanks.


  2. #2
    Join Date
    Aug 1999
    Posts
    12

    Re: PUT and InternetWriteFile

    Hi

    For me also the same error, file was created in the server side with 0kb size. When i call Write member function of CHttpFile it is throwing CInternetException error. Error is Invalid Handle. I am using MFC Class.

    There is one article MS KB. try this URL
    http://support.microsoft.com/support.../Q184/3/52.ASP

    Please let me know if you get any solution.
    sakjaba@yahoo.com


  3. #3
    Join Date
    Dec 1999
    Location
    Karnataka,India
    Posts
    2

    Re: PUT and InternetWriteFile

    hi,
    In fact I used the same code that is given in the KB. It fails without giving any error in any of the API calls.
    I find no documentation even in IIS side why the file won't be created.
    I am now using an ASP to POST the file data and let the ASP create the file I wanted to create using PUT method !
    Let me know if you come across any solution..




  4. #4
    Join Date
    Aug 1999
    Posts
    12

    Re: PUT and InternetWriteFile

    Hi,
    hReq = HttpOpenRequest (hConnect, "PUT", "/test/page.htm", ...)
    Here i am reading my local system file and copying the content into buffer, and passing that buffer to HttpSendRequest as szContent.
    HttpSendRequest (hReq, NULL, 0, szContent, lstrlen (szContent))

    Below there is my code wriiten in with MFC classes.
    pServer = session.GetHttpConnection(servername,INTERNET_INVALID_PORT_NUMBER,username,password);
    pFile = pServer->OpenRequest(_T("PUT"),pathout,NULL,1,&str,NULL,0/*INTERNET_FLAG_NO_CACHE_WRITE*/);

    CFile F;
    if (F.Open(filepath,CFile::modeRead))//local systemfile.
    {
    DWORD length = F.GetLength();
    DbgMsg("Logical length of the file %d",length);
    char* szBuff = new char[length+1];
    UINT nRead = F.Read(szBuff,length);
    DbgMsg("No. of bytes read %d",nRead);
    if(pFile->SendRequest(NULL,0,szBuff,nRead))
    dwRet = TRUE;
    delete szBuff;
    }

    I did the same thing like above but with MFC class.

    Regards
    jaba


  5. #5
    Join Date
    Jan 2000
    Posts
    11

    Re: PUT and InternetWriteFile

    Why not using HttpOpenRequest and HttpSendRequest?
    (With MFC without Http...)
    Regards
    Andreas


Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center