Error uploading file with QFtp [Solved]
-
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...