POCO 表单形式文件上传

HTTPRequest request(HTTPRequest::HTTP_POST, "/fileupload/upload_file.php",    HTTPMessage::HTTP_1_1);
    HTMLForm form;
    form.setEncoding(HTMLForm::ENCODING_MULTIPART);
    form.set("entry1", "value1");
    form.set("entry2", "value2");
    form.addPart("file", new FilePartSource("/home/abc/Pictures/sample.png"));
    form.prepareSubmit(request);

    HTTPClientSession *httpSession = new HTTPClientSession("localhost");
    httpSession->setTimeout(Poco::Timespan(20, 0));
    form.write(httpSession->sendRequest(request));        

    Poco::Net::HTTPResponse res;
    std::istream &is = httpSession->receiveResponse(res);
    Poco::StreamCopier::copyStream(is, std::cout);

你可能感兴趣的:(----c/c++)