Unsolved QHttpPart configuration
-
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
-
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); }