PHP<?php$fileHandler = fopen("./log.txt", "w");fwrite($fileHandler, serialize($_POST));fclose($fileHandler);echo "hello";?>
C++ (Qt)QUrl url("http://127.0.0.1/test.php? ");QByteArray body = "a=1&b=2"; QNetworkRequest request;request.setUrl(url);request.setHeader(QNetworkRequest::ContentLengthHeader, body.count());request.setRawHeader("User-Agent", "MyApp 1.0");request.setRawHeader("Host", url.encodedHost());request.setRawHeader("Cache-Control", "no-cache");request.setRawHeader("Content-Type", "text/html");request.setRawHeader("Accept", "*/*"); QNetworkAccessManager *mgr = new QNetworkAccessManager(this);QObject::connect(mgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(getResult(QNetworkReply*)));mgr->post(request, body);
C++ (Qt)QUrl url("http://127.0.0.1/test.php");QByteArray body = "a=1&b=2"; QNetworkRequest request;request.setUrl(url); QNetworkAccessManager *mgr = new QNetworkAccessManager(this);QObject::connect(mgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(getResult(QNetworkReply*)));mgr->post(request, body);
C++ (Qt)QByteArray body = "a=1&b=2";...mgr->post(request, body);
PHPArray( [a] => 1 [b] => 2)
PHPArray()
C++ (Qt)QNetworkRequest request(QUrl("http://127.0.0.1/test.php"));request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); // without it - does not workQByteArray body = "a=1&b=2";QNetworkAccessManager *mgr = new QNetworkAccessManager(this);connect(mgr, SIGNAL(finished(QNetworkReply*)), this, SLOT(getResult QNetworkReply*)));mgr->post(request, body);