में पॉको का उपयोग कर वेबर पर छवि अपलोड करने के लिए कैसे मैं दूरस्थ वेब सर्वर पर एक छवि अपलोड करने की कोशिश कर रहा हूं। मैंने HTMLForm और FilePartSource का उपयोग किया है। मैं स्थानीय सेवर (यानी loclhost) पर छवि को सफलतापूर्वक अपलोड करने में सक्षम हूं लेकिन जब मैं इसे दूरस्थ सर्वर में अपलोड करने का प्रयास करता हूं, तो दूरस्थ वेब सर्वर से प्राप्त प्रतिक्रिया "411 लंबाई आवश्यक" होती है। मैंने request.setContentLength (sizeofimagefile) सेट करने का प्रयास किया लेकिन फिर भी एक ही समस्या है। क्या कोई मुझे इस मुद्दे पर मार्गदर्शन कर सकता है या नहीं। यहां मेरा कोड है।पीओसीओ: सी ++
HTMLForm htmlform;
htmlform.set("aaaaaa", "bbbbbbb");
htmlform.set("cccccc", "ddddddd");
htmlform.setEncoding(HTMLForm::ENCODING_MULTIPART);
PartSource * pFileSrc = new FilePartSource("filename", "application/octet-stream");
std::istream& mystream = pFileSrc->stream();
mystream.seekg(0, std::ios::end);
int uiLength = mystream.tellg();
htmlform.addPart("file", pFileSrc);
URI uri("yyy");
HTTPClientSession session(uri.getHost(), uri.getPort());
HTTPRequest post_req(Poco::Net::HTTPRequest::HTTP_POST,"xxx",HTTPMessage::HTTP_1_1);
post_req.setKeepAlive(true);
htmlform.prepareSubmit(post_req);
std::ostream& oustr = session.sendRequest(post_req);
htmlform.write(oustr);
HTTPResponse res;
std::istream& rs = session.receiveResponse(res);
std::cerr << rs.rdbuf();
अग्रिम
सेटकंटेंट लम्बाई (sizeofimagefile) में, क्या आपने पैरामीटर "aaaaaa" और "cccccc" का आकार शामिल किया है जिसे आप अनुरोध डेटा में अपनी छवि के साथ भेजते हैं? यदि आप अपने फॉर्म के लिए POST विधि का उपयोग करते हैं, तो ये पैरा उसी डेटाबॉक पर जाते हैं, जिस छवि को आप अपलोड करने का प्रयास कर रहे हैं। –