Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt how to upload file in QNetworkAccessManager::post together with http query strings
QtWS25 Last Chance

Qt how to upload file in QNetworkAccessManager::post together with http query strings

Scheduled Pinned Locked Moved General and Desktop
6 Posts 6 Posters 11.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    today im sending simple post request like this :

    @QUrl params;
    QNetworkRequest request;
    params.addQueryItem("key","val");
    params.addQueryItem("key2","val2");
    request.setUrl("www.tst.com/test.php");
    QByteArray postArgs;
    postArgs = params.encodedQuery();
    QEventLoop loop;
    QNetworkReply *reply = networkManager->post(request,postArgs);
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec(); @

    every thing is working great , but now i need to add new parameter as file (image) to upload ogether with http query strings , how can it be done ?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You can find a snippet at last but one comment on this "qtcentre thread":http://www.qtcentre.org/threads/17564-file-upload-using-QNetworkRequest-amp-QNetworkAccessManager

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

        Also, 4.8 introduces the QHttpMultiPart class to manage multipart/form-data requests.
        A recommended reading is http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 .

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • R Offline
          R Offline
          raja26
          wrote on last edited by
          #4

          Git clone this git clone https://code.google.com/p/datacod-qt-tools/ or browse the code "Upcoder Source":http://code.google.com/p/datacod-qt-tools/source/browse/. You can find the code for uploading file in uploader.h and uploader.cpp.

          Otherwise there is a plugin for this task here. "Tuckdesign Qt":www.tuckdesign.com/sources/Qt.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            [quote author="raja26" date="1345198648"]Git clone this git clone https://code.google.com/p/datacod-qt-tools/ or browse the code "Upcoder Source":http://code.google.com/p/datacod-qt-tools/source/browse/. You can find the code for uploading file in uploader.h and uploader.cpp.

            Otherwise there is a plugin for this task here. "Tuckdesign Qt":www.tuckdesign.com/sources/Qt.[/quote]

            This topic is more than a year old. Please don't re-open such old topics just to add some new suggestions. It is more than likely the original poster has his issue long solved.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dhjdhj
              wrote on last edited by
              #6

              Except this thread is one of the first that shows up in a google search for this topic and I was quite pleased to see the newer and possibly better suggestion along with the original approach. Because of google, there's real value to keeping these things up to date even if they were started a long time ago.

              (Edit: spelling)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved