Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>QString body = "" ; const QUrl url("http://someurl.to/make/the/post" ); QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); QHttpPart textPartData; body = "" ; QTextStream(&amp;body) &lt;&lt; ""; textPartData.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=utf-8"); textPartData.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"data\"")); textPartData.setBody(body.toAscii()); for(int i=0; i&lt; number_of_files_to_send ; i++){ QHttpPart imagePart; QString header_body = ""; QTextStream(&amp;header_body) &lt;&lt; "form-data; name=\"" &lt;&lt; name_of_the_file &lt;&lt; "\"; filename=\"" &lt;&lt; name_of_the_file &lt;&lt; ".jpg\"" ; imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(header_body)); imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); //prepare file for upload QString filepath; QTextStream(&amp;filepath) &lt;&lt; FunkyPigeonBlackberry::getInstance()-&gt;dataModelProductDetails()-&gt;custom_image(i).value("cut_image").toString(); // pack the new file QFile *file = new QFile(filepath); file-&gt;open(QIODevice::ReadOnly); imagePart.setBodyDevice(file); file-&gt;setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart multiPart-&gt;append(imagePart); } multiPart-&gt;append(textPartData); multiPart-&gt;append(textPartProductDetails); multiPart-&gt;append(textPartDataDelivery); QNetworkRequest request(url); QNetworkReply* reply = m_networkAccessManager-&gt;post(request, multiPart); connect(reply, SIGNAL(finished()), this, SLOT(onNetworkResponse())); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload