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. QHttpPart configuration
Qt 6.11 is out! See what's new in the release blog

QHttpPart configuration

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 410 Views 1 Watching
  • 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.
  • K Offline
    K Offline
    Kaluss
    wrote on last edited by
    #1

    Hi,
    Im trying to prepare my post command where I send xml file to server, but I don't know how to set following line:

    names: <input type="file" name="namesFile" /><br />
    

    At the moment I have something like this:

       QHttpPart namesFilePart;
       namesFilePart.setHeader( QNetworkRequest::ContentDispositionHeader, QVariant( QString( " form-data; type=\"%1\"; name=\"%2\"" ).
                                                                                        arg( "file" ).arg( QFileInfo( namesFile ).fileName() ) ) );
       namesFilePart.setHeader( QNetworkRequest::ContentTypeHeader, QVariant( "application/xml" ) );
       namesFilePart.setBodyDevice( &namesFile );
       multiPart.append( namesFilePart );
    

    It doesn't work because I didn't set this "names:" mark before <input type="file" name="names" /><br />

    Can someone give me a hint how I can do that?

    BR/T

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! I'm not sure about this but I think setRawHeader should do the trick:

      void setNamesHeader(QString const &filename, QHttpPart &httpPart)
      {
          auto const headerName = QString("names");
          auto const headerValue = QString("<input type=\"file\" name=\"%1\" /><br />").arg(filename);
          httpPart.setRawHeader(headerName, headerValue);
      }
      
      1 Reply Last reply
      2

      • Login

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