title: QNetworkManager uploading file to FTP crash
body: <p>I am trying to upload a simple test text file to a FTP server. In order to achieve this I am using <a href="http://qt-project.org/doc/qt-5.1/qtnetwork/qnetworkaccessmanager.html" rel="nofollow">QNetworkAccessManager</a>, since <a href="http://qt-project.org/doc/qt-4.8/qftp.html" rel="nofollow">QFtp</a> has been deprecated in Qt 5.1.</p>
  
  <p>I created a test.txt file in the programs directory and using <a href="http://qt-project.org/doc/qt-5.1/qtcore/qfile.html" rel="nofollow">QFile</a> I am opening it as <code>QIODevice::ReadWrite | QIODevice::Text</code>. </p>
  
  <p>The problem is when I set the connection and tell the <a href="http://qt-project.org/doc/qt-5.1/qtnetwork/qnetworkaccessmanager.html" rel="nofollow">QNetworkAccessManager</a> to upload a file the program crashes ("FTPConnectionTest does not respond"). It happens both when I am trying to use an external FTP server or a local one created with <code>FileZilla</code>. </p>
  
  <p>I connected all signals emitted by the reply (functions: <code>uploadFinish</code>, <code>uploadProgress</code>, <code>uploadError</code>) however no feedback is beeing captured.</p>
  
  <p>Question: Is this problem lying on the side of FTP server or am I doing something wrong in my code?
  Code snipped below:</p>
  
  <p>Main.cpp</p>
  
  <pre><code>#include &lt;QCoreApplication&gt;
  #include &lt;ftp.h&gt;
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
      Ftp ftp;
      return a.exec();
  }
  </code></pre>
  
  <p>ftp.cpp</p>
  
  <pre><code>#include "ftp.h"
  #include &lt;QtNetwork/QNetworkAccessManager&gt;
  #include &lt;QtNetwork/QNetworkReply&gt;
  #include &lt;QtNetwork/QNetworkRequest&gt;
  #include &lt;QFile&gt;
  #include &lt;QUrl&gt;
  #include &lt;QDebug&gt;
  
  Ftp::Ftp()
  {   
      QFile file("test.txt");
      if (file.open(QIODevice::ReadWrite | QIODevice::Text)) {
          url = QUrl("ftp://127.0.0.1/test.txt");
          url.setUserName("user");
          url.setPassword("password");
  
          qDebug() &lt;&lt; "URL set" &lt;&lt; url;
  
          QNetworkAccessManager* nam = new QNetworkAccessManager();
          qDebug() &lt;&lt; "nam set";
          QNetworkReply *rep = nam-&gt;put(QNetworkRequest(url), &amp;file);
          qDebug() &lt;&lt; "after rep";
  
          connect(rep, SIGNAL(finished()), this, SLOT(uploadFinish()));
          connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(uploadError(QNetworkReply::NetworkError)));
          connect(rep, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64)));
      }
      else qDebug() &lt;&lt; "failed to open";
  }
  
  void Ftp::uploadFinish()
  {
      qDebug() &lt;&lt; "finished uploading file";
  }
  
  void Ftp::uploadProgress(qint64 a, qint64 b)
  {
      qDebug() &lt;&lt; a &lt;&lt; "/" &lt;&lt; b;
  }
  
  void Ftp::uploadError(QNetworkReply::NetworkError state)
  {
      qDebug() &lt;&lt; "State" &lt;&lt; state;
  }
  </code></pre>