....
QNetworkRequest req;
req.
setUrl(QUrl("https://192.168.2.1/input.php"));
req.setRawHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
QNetworkAccessManager *manager = new QNetworkAccessManager;
incoming
= new QFile("file.xml");
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(filesenderror(QNetworkReply*)));
reply2 =manager->post(req,datas);
connect(reply2,SIGNAL(readyRead()),this,SLOT(readfile()));
connect(reply2,SIGNAL(finished()),this,SLOT(writefile()));
connect(reply2,SIGNAL(finished()),incoming,SLOT(deleteLater()));
connect(reply2,SIGNAL(finished()),manager,SLOT(deleteLater()));
reply2->ignoreSslErrors();
reply2->request();
....
....
QNetworkRequest req;
req.setUrl(QUrl("https://192.168.2.1/input.php"));
req.setRawHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
QNetworkAccessManager *manager = new QNetworkAccessManager;
incoming= new QFile("file.xml");
incoming->open(QIODevice::WriteOnly);
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(filesenderror(QNetworkReply*)));
reply2 =manager->post(req,datas);
connect(reply2,SIGNAL(readyRead()),this,SLOT(readfile()));
connect(reply2,SIGNAL(finished()),this,SLOT(writefile()));
connect(reply2,SIGNAL(finished()),incoming,SLOT(deleteLater()));
connect(reply2,SIGNAL(finished()),manager,SLOT(deleteLater()));
reply2->ignoreSslErrors();
reply2->request();
....
To copy to clipboard, switch view to plain text mode
void MainWindow::filesenderror(QNetworkReply *reple)
{
if (reple->error() !=0)
{
if (reple->error() == 1 )
{
QMessageBox::critical(this,
"Connection Problem",
"Connection Refused");
return;
}
else
{
QMessageBox::critical(this,
"Connection Problem",reple
->errorString
());
return;
}
}
else
{
ui->label_13->setText("Download progress complete");
}
}
void MainWindow::filesenderror(QNetworkReply *reple)
{
if (reple->error() !=0)
{
if (reple->error() == 1 )
{
QMessageBox::critical(this,"Connection Problem", "Connection Refused");
return;
}
else
{
QMessageBox::critical(this,"Connection Problem",reple->errorString());
return;
}
}
else
{
ui->label_13->setText("Download progress complete");
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks