I am trying to upload a file on the server. I have written this code, but i am receiving error in reply from server (on call of uploadfinished() [in code])

Qt Code:
  1. uploadmanager::uploadmanager()
  2. {
  3. connect(&manager, SIGNAL(finished(QNetworkReply*)),
  4. SLOT(uploadFinished(QNetworkReply*)));
  5. }
  6.  
  7.  
  8. void uploadmanager::doUpload()
  9. {
  10. QString message_d = QString("Unable to open file");
  11. args<<"E:\\SMS\\spam_freq.csv";
  12. foreach (QString arg, args) {
  13. QFile file(arg);
  14. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
  15. {
  16. QMessageBox::information(this, "Error", message_d);
  17. return;
  18. }
  19.  
  20. QNetworkRequest request;
  21. request.setUrl(QUrl("me.xyz.com/smsspam"));
  22. request.setRawHeader("Content-type", "application/x-www-form-urlencoded");
  23. request.setRawHeader("Accept","text/plain");
  24. file.open(QIODevice::ReadOnly | QIODevice::Text);
  25. QByteArray fileBinaryData(file.readAll());
  26. file.close();
  27. request.setRawHeader("data",fileBinaryData);
  28. QNetworkReply *reply = manager.post(request, fileBinaryData);
  29. currentUploads.append(reply);
  30. }
  31.  
  32. }
  33.  
  34. void uploadmanager::uploadFinished(QNetworkReply *reply)
  35. {
  36.  
  37. if (reply->error())
  38. {
  39. QString message_er = QString("Error in Upload");
  40. QMessageBox::information(this, "Err", message_er); //I am getting this msg
  41. }
  42. else
  43. {
  44. QString message_d = QString("Upload Complete");
  45. QMessageBox::information(this, "Upload Complete", message_d);
  46.  
  47. }
  48.  
  49. currentUploads.removeAll(reply);
  50. reply->deleteLater();
  51.  
  52. if (currentUploads.isEmpty())
  53. return;
  54.  
  55. }
To copy to clipboard, switch view to plain text mode 


The PHP script at the server is below:

Qt Code:
  1. <?php
  2. // Read the raw http data from the post
  3. $data = $_POST['data'];
  4. // Ungzip the wav file
  5. // $chunk = gzuncompress($data);
  6. if (!$data) {
  7. echo -1;
  8. die();
  9. }
  10. $uid = uniqid();
  11. $filename = "$uid.csv";
  12. $filepathname = "uploads/$filename";
  13. $handle = fopen($filepathname, 'wb');
  14. fputs($handle, $data, strlen($data));
  15. fclose($handle);
  16. ?>
To copy to clipboard, switch view to plain text mode 

Kindly, help me in constructing packet header and request in correct format as per the script. I think, i am not doing that in right way.

Any help would be appreciated.