Upload file using HTTP. getting error :- HttpSendReuest 12005

后端 未结 1 560
迷失自我
迷失自我 2021-01-26 14:23

I want to upload \"D:\\er.txt\" to webserver using HTTP, when I am running program, i got HttpSendRequest 12005 as an error. i used a PHP script on my webserver that will accep

相关标签:
1条回答
  • 2021-01-26 14:55

    According to the docs for HttpOpenRequest, the lplpszAcceptTypes argument should change from

    (const char**)"*/*\0"
    

    to

    {_T("*/*"), NULL}
    

    You can also remove the \0 from the end of the string. You don't need to manually insert a nul terminator to a string literal.

    In other words, you need to change

    HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",
                                         _T("upload.php"), NULL, NULL,
                                         (const char**)"*/*\0", 0, 1);
    

    to

    LPCTSTR rgpszAcceptTypes[] = {_T("*/*"), NULL};
    HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",
                                         _T("upload.php"), NULL, NULL,
                                         rgpszAcceptTypes, 0, 1);
    
    0 讨论(0)
提交回复
热议问题