Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem Using QNetworkAccessManager ftp (SOLVED)
Forum Updated to NodeBB v4.3 + New Features

Problem Using QNetworkAccessManager ftp (SOLVED)

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 8.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jako87
    wrote on last edited by
    #1

    @QFile *fichero=new QFile("C://a/prueba.txt",this);
    if (fichero->open(QIODevice::ReadWrite)){

        QUrl direccion("ftp://pi:raspberry@192.168.1.130/home/pi/proyecto/prueba.txt");
    
        QNetworkAccessManager *nman=new QNetworkAccessManager();
        connect(nman,SIGNAL(finished(QNetworkReply*)),this,SLOT(terminareq(QNetworkReply*)));
        QNetworkRequest req;
        req.setUrl(direccion);
    
        nman->put(req,fichero);
        fichero->close();
    }@
    

    When I put the file i only have a empty file in my server. What's the problem here??? I'm so worried with this!!!!

    PD: when i capture de qnetworkreply data is an Unknow error

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      There are the compatibility "addons with QtFtp.":https://qt.gitorious.org/qt/qtftp In there you can see, how to do an ftp transfer.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jako87
        wrote on last edited by
        #3

        I don't find i was lookin for. Is normal that the connexion have been made but the file is empty???

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jako87
          wrote on last edited by
          #4

          I have just solved!!!! The problem is that fichero must be open while the writing is running until the signal finished is emited.
          @void QHorarioCompleto::pulsaenviar()
          {
          fichero=new QFile("C://a/prueba.txt",this);
          if (fichero->open(QIODevice::ReadWrite)){

              QUrl direccion("ftp://pi:raspberry@192.168.1.130/home/pi/proyecto/prueba.txt");
          
          
              QNetworkAccessManager *nman=new QNetworkAccessManager();
              connect(nman,SIGNAL(finished(QNetworkReply*)),this,SLOT(terminareq(QNetworkReply*)));
              QNetworkRequest req;
          
              req.setUrl(direccion);
          
              nman->put(req,fichero);
          
          
          }
          

          }
          void QHorarioCompleto::terminareq(QNetworkReply *respuesta)
          {
          fichero->close();
          qDebug() << "Finished ";
          qDebug()<<respuesta->errorString();
          }@
          This works really good!!! Share it!!!

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved