PDA

View Full Version : Couldn't change current directory in windows's QT



sinha.ashish
24th February 2008, 12:41
Following program is to upload a file from local system to a remote sever.But the file on server after uploading have zero bytes.Correct uploading take place only when i put the file to upload in my application's release folder.Changing the current directory failed.Please help me..:confused:


if(QDir::setCurrent(path))
qDebug()<<"path set";
else
qDebug()<<"Couldn't set path";
QFile *file = new QFile(filename);
file->open( QIODevice::ReadWrite );
ftp.connectToHost("192.100.1.00");
ftp.login("ftp","ftp");
QFileInfo fi(media);
ftp.put(file,fi.fileName(),QFtp::Binary);
ftp.close();

marcel
24th February 2008, 12:45
QFtp::put returns a command ID. You must save this ID and connect a slot to the QFtp::commandFinished signal. When you get that ID you can be sure that the upload has been completed and close the connection.

Your current code closes the connection immediately, there is no transfer performed.

wysota
24th February 2008, 12:50
Your current code closes the connection immediately, there is no transfer performed.

QFtp::close() only schedules a disconnection - it doesn't perform it immediately.

@sinha.ashish: What is the contents of "filename"?

sinha.ashish
25th February 2008, 05:00
Thanks for the post. Problem solved...there was a problem in seting path of file to be uploaded now it is corrected