uploadmanager::uploadmanager()
{
connect(&manager, SIGNAL(finished(QNetworkReply*)),
SLOT(uploadFinished(QNetworkReply*)));
}
void uploadmanager::doUpload()
{
args<<"E:\\SMSAssassin\\spam_freq.csv";
{
return;
}
QNetworkRequest request;
request.
setUrl(QUrl("http://ddd.myserver.com/smssp/uploads/"));
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
file.close();
QNetworkReply *reply = manager.put(request, fileBinaryData);
currentUploads.append(reply);
}
}
void uploadmanager::uploadFinished(QNetworkReply *reply)
{
//QUrl url = reply->url();
if (reply->error())
{
}
else
{
QMessageBox::information(this,
"Upload Complete", message_d
);
}
currentUploads.removeAll(reply);
reply->deleteLater();
if (currentUploads.isEmpty())
return;
}
uploadmanager::uploadmanager()
{
connect(&manager, SIGNAL(finished(QNetworkReply*)),
SLOT(uploadFinished(QNetworkReply*)));
}
void uploadmanager::doUpload()
{
QStringList args;
QString message_d = QString("Unable to open file");
args<<"E:\\SMSAssassin\\spam_freq.csv";
foreach (QString arg, args) {
QFile file(arg);
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::information(this, "Error", message_d);
return;
}
QNetworkRequest request;
request.setUrl(QUrl("http://ddd.myserver.com/smssp/uploads/"));
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
file.open(QIODevice::ReadOnly);
QByteArray fileBinaryData(file.readAll());
file.close();
QNetworkReply *reply = manager.put(request, fileBinaryData);
currentUploads.append(reply);
}
}
void uploadmanager::uploadFinished(QNetworkReply *reply)
{
//QUrl url = reply->url();
if (reply->error())
{
QString message_er = QString("Error in Upload");
QMessageBox::information(this, "Err", message_er);
}
else
{
QString message_d = QString("Upload Complete");
QMessageBox::information(this, "Upload Complete", message_d);
}
currentUploads.removeAll(reply);
reply->deleteLater();
if (currentUploads.isEmpty())
return;
}
To copy to clipboard, switch view to plain text mode
Bookmarks