[Qt-interest] HTTP post of several files' data

Qt Quest qt.quest at yahoo.com
Thu Mar 4 03:15:45 CET 2010


Hi All,

I'm trying to write an HTTP POST code which will upload several files in the same request.
However, I do not know understand how to delimit each file parameter, since '&' could be in the body of the files.
What is the proper way to do it? base64? Should I set any request headers?
Below is the code I currently use. No HTTP headers are being set up.
Has anybody done this before? Is there a full HTTP file upload sample somewhere?
Thank you for any reply!

---
    QFile *file1=...,*file2=...;
    QNetworkRequest req(QUrl(SEND_FILE_URL));
    QString body="subject="+subject;
    QByteArray babody = QString("&file1=").append(file1->readAll()).append("&file2=").append(file2->readAll());
    reply = networkManager.post(req, babody);
    




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100303/9a558b95/attachment.html 


More information about the Qt-interest-old mailing list