I take part of this code on Qt Programming ... forum ..... and not running...

I have 2 choise webdav ( http://www.webdav.org/neon/ & make libs ) upload or
QHttp qt 4.1.3 upload ...

class here running and signal is incomming....
but 0 KB upload.... Why?

full code is on svn http://ciz.ch/svnciz/_STATIC_LIBS_QT4/upload_test/


Qt Code:
  1. #include "gui_upload.h"
  2. //
  3. /* Save file as gui_upload.cpp */
  4. /* Class Gui_Upload Created on Wed Jun 7 10:17:12 CEST 2006 */
  5. //
  6. #include <QCloseEvent>
  7. //
  8. QPointer<Gui_Upload> Gui_Upload::_self = 0L;
  9. //
  10. Gui_Upload* Gui_Upload::self( QWidget* parent )
  11. {
  12. if ( !_self )
  13. _self = new Gui_Upload( parent );
  14. return _self;
  15. }
  16. Gui_Upload::Gui_Upload( QWidget* parent )
  17. : QDialog( parent )
  18. {
  19. setupUi( this );
  20. qDebug() << "### class init ";
  21. connect(pushButton , SIGNAL(clicked()), this , SLOT(BeginnJob()));
  22. }
  23.  
  24. void Gui_Upload::FinishStream()
  25. {
  26. QMessageBox::information(this, tr("HTTP"),tr("Signal finisch!"));
  27. }
  28. void Gui_Upload::BeginnJob()
  29. {
  30. QString us = username->text();
  31. QString pa = pass->text();
  32. QString openFilesPath = "/";
  33.  
  34. if (us.size() < 1 or pa.size() < 1) {
  35. QMessageBox::information(this, tr("HTTP"),tr("User Name or Pass not set!"));
  36. return;
  37. }
  38. qDebug() << "### user " << us;
  39. qDebug() << "### pass " << pa;
  40. qDebug() << "### openFilesPath " << openFilesPath;
  41.  
  42. QString fileName = QFileDialog::getOpenFileName(this,tr("OpenFile"),openFilesPath,tr("All Files (*);;Text Files (*.txt)"));
  43. if (!fileName.isEmpty()) {
  44. openFilesPath = fileName;
  45. qDebug() << "### openFilesPath " << openFilesPath;
  46. QFileInfo path(openFilesPath);
  47. QString fileName1 = path.fileName();
  48. userfile = new QFile(openFilesPath);
  49. if ( !userfile->open(QIODevice::ReadOnly) ) {
  50. QMessageBox::information(this, tr("HTTP"),tr("Unable to open the file %1: %2.").arg(openFilesPath).arg(userfile->errorString()));
  51. return;
  52. }
  53. pushButton->setEnabled(false);
  54.  
  55. /* dear qt set and splitt the url self */
  56. QUrl url("http://ppk.go/qt/tools.php");
  57. QHttpRequestHeader header("POST", url.path());
  58. header.setValue("Host", url.host());
  59. header.setValue("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.12) Gecko/20050919 Firefox/1.0.7");
  60. header.setValue("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
  61. header.setValue("Accept-Language", "de-de,it;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
  62. header.setValue("Accept-Encoding", "gzip,deflate");
  63. header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
  64. header.setValue("Keep-Alive", "300");
  65. header.setValue("Connection", "keep-alive");
  66. header.setValue("Referer", "http://ppk.go/");
  67. header.setValue("Content-Type", "application/x-www-form-urlencoded");
  68.  
  69. QByteArray byt(openFilesPath.toUtf8());
  70. QByteArray bytes;
  71. bytes.append("--AaB03x\r\n");
  72. bytes.append("content-disposition: ");
  73. bytes.append("form-data; name=\"onlyclient\" username=\""+us+"\" password=\""+pa+"\" action=\"beamup\" \r\n");
  74. bytes.append("\r\n");
  75. bytes.append("0\r\n");
  76. bytes.append("--AaB03x\r\n");
  77. bytes.append("content-disposition: ");
  78. bytes.append("form-data; name=\"qtfile\"; filename=\"" + byt+ "\"\r\n");
  79. bytes.append("Content-Transfer-Encoding: binary\r\n");
  80. bytes.append("\r\n");
  81. bytes.append(userfile->readAll());
  82. userfile->close();
  83. bytes.append("\r\n");
  84. bytes.append("--AaB03x--");
  85.  
  86. int contentLength = bytes.length();
  87. header.setContentLength(contentLength);
  88.  
  89. qDebug() << "### stream " << bytes;
  90.  
  91. /* real post */
  92. http = new QHttp(this);
  93. int httpGetId = http->request(header, bytes);
  94. qDebug() << "### httpGetId " << httpGetId;
  95. /* real post */
  96. connect(http, SIGNAL(done(bool)), this, SLOT(FinishStream()));
  97. }
  98.  
  99. }
  100.  
  101. void Gui_Upload::closeEvent( QCloseEvent* e )
  102. {
  103. e->accept();
  104. }
To copy to clipboard, switch view to plain text mode 

the form is so ... and firefox upload sucessfull....

Qt Code:
  1. <form action="tools.php" method="post" enctype="multipart/form-data" name="onlyclient" id="onlyclient">
  2. <input type="hidden" name="action" value="beamup">
  3. Username:<br/><input type="text" name="username"><br/><br/>
  4. Password:<br/><input type="password" name="password"><br/><br/>
  5.  
  6. Your File:<BR><input type=file name=qtfile><BR><BR>
  7. <input type=submit name=submit value="Upload">
  8. </form>
To copy to clipboard, switch view to plain text mode