Problem solved!!For someone else who has similar problem.
This code works..
crlf = 0x0d;
crlf.append(0x0a);
data = "--" + bound + crlf + "Content-Disposition: form-data; name=\"uploadedfile\"; ";
data.
append(QString("filename=\"%1\";").
arg(filePath
));
data.append(crlf + "Content-Type: application/octet-stream" + crlf + crlf);
postData.insert(0,data);
postData.append(file.readAll());
postData.append(crlf + "--" + bound + "--" + crlf);
QUrl url
("http://localhost/uploadedFile.php");
QNetworkRequest req(url);
req.setHeader(QNetworkRequest::ContentTypeHeader, tr("multipart/form-data; boundary="));
file.close();
manager->post(req,postData);
connect(manager,SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));
QString bound;
QString crlf;
QString data;
QByteArray postData;
crlf = 0x0d;
crlf.append(0x0a);
data = "--" + bound + crlf + "Content-Disposition: form-data; name=\"uploadedfile\"; ";
data.append(QString("filename=\"%1\";").arg(filePath));
data.append(crlf + "Content-Type: application/octet-stream" + crlf + crlf);
postData.insert(0,data);
postData.append(file.readAll());
postData.append(crlf + "--" + bound + "--" + crlf);
QUrl url("http://localhost/uploadedFile.php");
QNetworkRequest req(url);
req.setHeader(QNetworkRequest::ContentTypeHeader, tr("multipart/form-data; boundary="));
file.close();
manager->post(req,postData);
connect(manager,SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));
To copy to clipboard, switch view to plain text mode
And if wou want to delete file from the server then the code is more than a simple:
data.
append(QString("packageName=%1").
arg(ui
->softwareNameEdit
->text
()));
postData.append(data);
QUrl url
("http://localhost/deleteUploadFile.php/");
QNetworkRequest req(url);
manager->post(req,postData);
data.append(QString("packageName=%1").arg(ui->softwareNameEdit->text()));
postData.append(data);
QUrl url("http://localhost/deleteUploadFile.php/");
QNetworkRequest req(url);
manager->post(req,postData);
To copy to clipboard, switch view to plain text mode
However,thank's for your answers!!!
Bookmarks