Results 1 to 3 of 3

Thread: Again QNetworkAccessManager POST and PHP

  1. #1
    Join Date
    Jan 2014
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Again QNetworkAccessManager POST and PHP

    Hello. I have got a problem, I'm sitting on it all day long, and have no idea what is wrong.

    Qt Code:
    Qt Code:
    1. manager = new QNetworkAccessManager;
    2. QUrl param;
    3. param.addQueryItem("file","sometext");
    4. QByteArray postData;
    5. postData.append(param.encodedQuery());
    6.  
    7. QNetworkRequest request;
    8. request.setUrl(QUrl("http://localhost/file.php"));
    9. request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream");
    10. manager->post(request,postData);
    11. connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(downloadFinished(QNetworkReply*)));
    To copy to clipboard, switch view to plain text mode 

    And in downloadFinished: reply->readAll() (with checking for errors etc). Server is giving me response, but without variable from $_POST ($_POST array is empty). My php script file.php:

    Qt Code:
    1. if( $_POST['file'] )
    2. {
    3. echo "Filename is ". $_POST['file']. "<br />";
    4. }
    To copy to clipboard, switch view to plain text mode 

    Anyone know what can be wrong? Please help

  2. #2
    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: Again QNetworkAccessManager POST and PHP

    You are telling the script that the payload is an opaque collection of bytes rather than either a url encoded or multipart MIME form data payload.

  3. #3
    Join Date
    Jan 2014
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Again QNetworkAccessManager POST and PHP

    Yeah, my mistake Problem solved.

Similar Threads

  1. QNetworkAccessManager post
    By januszmk in forum Newbie
    Replies: 2
    Last Post: 13th April 2012, 09:01
  2. QNetworkAccessManager and post method
    By sabbu in forum Newbie
    Replies: 12
    Last Post: 16th June 2011, 23:01
  3. POST and QNetworkAccessManager
    By hakermania in forum Newbie
    Replies: 1
    Last Post: 13th February 2011, 00:05
  4. QNetworkAccessManager::post() never returns
    By danc81 in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2009, 09:13
  5. QNetworkAccessManager double post
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 04:44

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.