<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How can i send file over http with Qt?]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I have .bin file and i want to upload this file via http i tried following code, but not happened anything.</p>
<pre><code>QFile* file = new QFile("C:/Users/Hp/Desktop/FileTest/2022-12-16 15-09-21.bin");
QHttpMultiPart * multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHttpPart filePart;

file-&gt;open(QIODevice::ReadOnly);

filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/zip")); //or whatever type of your file.
filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"bin\""));
filePart.setHeader(QNetworkRequest::ContentLengthHeader, file-&gt;size());
file-&gt;setParent(multiPart);

filePart.setBodyDevice(file);
multiPart-&gt;append(filePart);

QNetworkAccessManager mgr;
QNetworkRequest req(QUrl("some/url"));
//req.setRawHeader("Authorization", ("Token &lt;token&gt;"));
&lsqb;&lsqb;maybe_unused&rsqb;&rsqb; QNetworkReply * reply = mgr.post(req, multiPart);
</code></pre>
<p dir="auto">Thanks for helps.</p>
]]></description><link>https://forum.qt.io/topic/142994/how-can-i-send-file-over-http-with-qt</link><generator>RSS for Node</generator><lastBuildDate>Thu, 04 Jun 2026 03:49:12 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142994.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Feb 2023 09:17:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can i send file over http with Qt? on Thu, 16 Feb 2023 20:33:40 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Beside <a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> suggestions, what is the lifetime of mgr ?<br />
You also don't do any error checks which is a bad idea.</p>
]]></description><link>https://forum.qt.io/post/748017</link><guid isPermaLink="true">https://forum.qt.io/post/748017</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 16 Feb 2023 20:33:40 GMT</pubDate></item><item><title><![CDATA[Reply to How can i send file over http with Qt? on Thu, 16 Feb 2023 10:07:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yaldiz">@<bdi>Yaldiz</bdi></a> said in <a href="/post/747910">How can i send file over http with Qt?</a>:</p>
<blockquote>
<p dir="auto">but not happened anything.</p>
</blockquote>
<p dir="auto">Did you check what the <code>reply</code> object returned had to say?  Did you receive the <code>QNetworkAccessManager</code>/<code>QNetworkReply::finished</code> signals?  What about the <code>file-&gt;open()</code> call just to be sure?  Is the Url <code>http</code> and not <code>https</code>?</p>
]]></description><link>https://forum.qt.io/post/747918</link><guid isPermaLink="true">https://forum.qt.io/post/747918</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 16 Feb 2023 10:07:33 GMT</pubDate></item></channel></rss>