Hello everyone,

I am trying to upload a file on a server and I have found a code on this page how to upload a file on server but I don't know if it works.
And I want to check if my code does realy upload them on the server
How can I check if it is realy uploaded or not

QErrorMessage msg;
QString usersfilename = QFileDialog::getOpenFileName();
QDir dir = QFileInfo(usersfilename).absoluteDir();
qDebug() << dir;
qDebug() << usersfilename;
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentTypeHe ader, QVariant("text/plain"));
imagePart.setHeader(QNetworkRequest::ContentDispos itionHeader, QVariant("form-data;name=filename;filename="+usersfilename));


QHttpPart textPart;

textPart.setBody("file");


QFile *file = new QFile(usersfilename);
file->open(QIODevice::ReadOnly);
imagePart.setBodyDevice(file);
file->setParent(multiPart);
multiPart->append(textPart);
multiPart->append(imagePart);

QUrl url("http://example.com/post");
QNetworkRequest request(url);
qDebug() << url;

QNetworkAccessManager *manager= new QNetworkAccessManager;
QNetworkReply *reply = manager->post(request, multiPart);
multiPart->setParent(reply); // delete the multiPart with the reply


qDebug() <<"reply: " << reply;



qDebug() << reply->header(QNetworkRequest::ContentTypeHeader).toStri ng();
qDebug() << reply->header(QNetworkRequest::LastModifiedHeader).toDat eTime().toString();
qDebug() << reply->header(QNetworkRequest::ContentLengthHeader).toUL ongLong();
qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribut e).toInt();
qDebug() << reply->attribute(QNetworkRequest::HttpReasonPhraseAttrib ute).toString();






if (reply->error() == QNetworkReply::NoError)
{

QString strReply = (QString)reply->readAll();

//parse json
qDebug() << "Response:" << strReply;
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
QJsonObject jsonObj = jsonResponse.object();
QJsonObject result=jsonObj["result"].toObject();

if(jsonObj["error"].toBool()==false)

{
QJsonObject data=result["data"].toObject();
QMessageBox::information(this, tr("Uploaded Successful"),
tr(""%1"uploaded successfully").arg("File"));

}
else
{
QErrorMessage msg;
msg.showMessage("Error during upload proces");
msg.exec();
}
delete reply;
}