Hi,
I use QFtp class in order to upload my files to server but after ftp->put I find that files are empty in server
I do not understand what is the problem in the code
My code is here
Qt Code:
  1. QFtp *ftp = new QFtp(this);
  2. ftp->setTransferMode(QFtp::Passive);
  3. //connect(ftp,SIGNAL(commandFinished ( int, bool)),this,SLOT(fincommande()));
  4. ftp->connectToHost("ftp.icwus.net",21);
  5. //setValueProgressBar(25);
  6.  
  7. connect(ftp, SIGNAL(stateChanged(int)), this, SLOT(showNewState(int)));
  8.  
  9. connect( ftp, SIGNAL( commandFinished( int, bool )),this, SLOT( ftp_commandFinished( int, bool )) );
  10. connect( ftp, SIGNAL( commandFinished( int, bool )),this, SLOT( ftp1_commandFinished( int, bool )) );
  11.  
  12. ftp->login("mylogin","mypassword");
  13. ftp->cd("acrgafsa");
  14. ftp->mkdir("timetables");
  15. ftp->cd("timetables");
  16.  
  17. int i = 0;
  18. QString filename;
  19. QString files = QFileDialog::getOpenFileName(this, tr("Select File"),
  20. "D://");
  21.  
  22. if (files.isEmpty())
  23. return;
  24.  
  25. while(files.indexOf("/", i) != (-1)) //find the file name not include the full url
  26. i = files.indexOf("/",i) + 1;
  27. while(i < files.size())
  28. {
  29. filename.append(files.at(i));
  30.  
  31. i++;
  32. }
  33.  
  34. QFile *file = new QFile(filename);
  35.  
  36. Q_ASSERT(file != NULL);
  37.  
  38. if(!file->open(QIODevice::ReadWrite)) //finished create the file in the debug file
  39. {
  40. qDebug() << "opern err" << file->fileName();
  41. return;
  42. }
  43.  
  44. ftp->put(file,filename);
To copy to clipboard, switch view to plain text mode