PDA

View Full Version : Again QNetworkAccessManager POST and PHP



ZSWASW
14th February 2014, 22:35
Hello. I have got a problem, I'm sitting on it all day long, and have no idea what is wrong.

Qt Code:


manager = new QNetworkAccessManager;
QUrl param;
param.addQueryItem("file","sometext");
QByteArray postData;
postData.append(param.encodedQuery());

QNetworkRequest request;
request.setUrl(QUrl("http://localhost/file.php"));
request.setHeader(QNetworkRequest::ContentTypeHead er, "application/octet-stream");
manager->post(request,postData);
connect(manager,SIGNAL(finished(QNetworkReply*)),t his,SLOT(downloadFinished(QNetworkReply*)));


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:



if( $_POST['file'] )
{
echo "Filename is ". $_POST['file']. "<br />";
}


Anyone know what can be wrong? Please help

ChrisW67
15th February 2014, 04:00
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.

ZSWASW
2nd March 2014, 19:38
Yeah, my mistake ;) Problem solved.