CHttpFile and CHttpConnection to upload file


  • I've a *.php file in my host "". "upload.php" contain upload code. How can i use CHttpConnection and CHttpFile to send request to "upload.php" to upload a file to my host?(Like web browser).
    • Edited by thanhvinh Wednesday, July 29, 2009 4:57 PM
    Wednesday, July 29, 2009 4:47 PM


  • Hello,

    Usually the steps are:

    1. Create a CInternetSession.
    2. Use the session to get CHttpConnection.
    3. Call CHttpConnection::OpenRequest() to get CHttpFile.
    4. Call CHttpFile::SendRequest() to send request.
    5. Call CHttpFile::QueryInfoStatusCode() to query the status.

    Then use CHttpFile::Read() to see the response.
    You could find many samples on the web, if you need simulating the Form Post, take a look at this article: How to simulate a Form POST request by using WinInet

    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Wesley Yao Wednesday, August 05, 2009 2:49 AM
    Friday, July 31, 2009 10:20 AM