Results 1 to 18 of 18

Thread: Http Posting using QNetworkAccessManager

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Http Posting using QNetworkAccessManager

    Your multipart form data needs to include the other elements of the form. In this case the submit button.
    Qt Code:
    1. imagePart = QtNetwork.QHttpPart()
    2. imagePart.setHeader(QtNetwork.QNetworkRequest.ContentDispositionHeader,
    3. "form-data; name=\"%s\"; filename=\"%s\"" % (key, fileName))
    4. imagePart.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader,
    5. 'image/jpeg')
    6. imagePart.setBodyDevice(self._stream)
    7.  
    8. submitPart = QtNetwork.QHttpPart()
    9. submitPart.setHeader(QtNetwork.QNetworkRequest.ContentDispositionHeader,
    10. "form-data; name=\"submit\"")
    11. submitPart.setBody("submit")
    12.  
    13. self._multiPart.append(imagePart)
    14. self._multiPart.append(submitPart)
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to ChrisW67 for this useful post:

    Mohammadhzp (24th January 2014)

Similar Threads

  1. Replies: 2
    Last Post: 8th January 2014, 15:40
  2. Replies: 4
    Last Post: 2nd May 2012, 12:51
  3. QNetworkAccessManager and http redirection
    By grayfox in forum Qt Programming
    Replies: 5
    Last Post: 8th July 2011, 17:24
  4. HTTP Post from QNetworkAccessManager - no data sent
    By secureboot in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2011, 18:46
  5. QNetworkAccessManager Http Basic Authentication?
    By jloundy in forum Qt Programming
    Replies: 5
    Last Post: 29th December 2010, 00:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.