Problem in Http file upload
I am trying to upload a .csv file on my server. Referring the documentation, i have written the following code. But, there is some problem and it's not working.
I am calling doUpload() for the upload action:
Code:
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;
}
Any help will be appreciated.
Re: Problem in Http file upload
Quote:
But, there is some problem and it's not working.
The first step is to debug the code.
Step through doUbload() and look which code is not behaving as it should.
Your code makes almost no tests for many of the calls you make, so any of those could be failing.
Once you know which line of code is the problem, we can look more in to it.