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. Error uploading file with QFtp [Solved]
Forum Update on Monday, May 27th 2025

Error uploading file with QFtp [Solved]

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 4.0k Views
  • 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.
  • V Offline
    V Offline
    vezprog
    wrote on 27 Jul 2012, 18:17 last edited by
    #1

    My setup is a Qt application which acts as the client for the FTP server using QFtp. The server where I am trying to upload a file to is a Linux box running vsftpd.

    The issue I am having is that I am able to connect successfully, also I am able to login. But when I try to "put" a file (at the moment I am trying to send a tar.gz), the file gets created on the linux side, but the file size is always ends up being 0.

    On the windows application running QFtp, the signal for the data transfer gets emitted and it claims that all of the bytes are sent successfully (about 145kbs, its just 2 text files packaged for right now).

    Heres some example code that I am doing.

    Initially all I call to connect to the ftp server is:
    @
    /* file for sending */
    sendFile = new QFile();

    /* ftp server socket */
    ftpServer = new QFtp(this);
    connect(ftpServer, SIGNAL(stateChanged(int)), this, SLOT(ftpStateChanged(int)));
    connect(ftpServer, SIGNAL(dataTransferProgress(qint64,qint64)), this, SLOT(ftpDataTransferProgress(qint64,qint64)));
    ftpServer->connectToHost(ipAddress, 21);
    @

    Heres my slots:
    @
    /*
    // ftp state changed (slot)
    /
    void Updater::ftpStateChanged(int state)
    {
    switch (state){
    case 0:
    case 1:
    case 2:
    case 3:
    /
    update the ui for a successful connection */
    ui->textedit_log->append("Connected to file transfer server");
    ui->textedit_log->append("Attempting login");

            /* attempt login to ftp server */
            ftpServer->login("username", "password");
            break;
        case 4:
            /* start sending the file */
            sendFile->setFileName(selectedFile);
            sendFile->open(QFile::ReadOnly);
            ftpServer->put(sendFile, "package.tar.gz");
            break;
    }
    

    }

    /*
    // ftp data transfer progress (private slot)
    /
    void Updater::ftpDataTransferProgress(qint64 done, qint64 total)
    {
    /
    update the log text */
    QString logText = "Transfered " + QVariant(done).toString() + " out of " + QVariant(total).toString();
    ui->textedit_log->append(logText);

    /* check if the transfer is complete */
    if (done == total){
        qDebug() << "Transfer complete";
    }
    

    }
    @

    Any ideas on what I could be doing wrong? One red flag that I am looking into is when I run the example ftp program in the QtSDK, after the initial connect, a list does not pop up, the directory is empty and I automatically direct the logged in users to the home directory of the login name...

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on 27 Jul 2012, 19:03 last edited by
      #2

      Nevermind I figured it out. The file buffer on the send was wrong...oops :) Good now though!

      1 Reply Last reply
      0

      1/2

      27 Jul 2012, 18:17

      • Login

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