PDA

View Full Version : Download File



BalaQT
12th February 2010, 14:21
hi,
im using qt4.5.2 in debian. i want to download a file from web.
so i used the following code


QNetworkAccessManager *manager=new QNetworkAccessManager;
QString url="ftp://ftp.trolltech.com/qt/source/INSTALL";
QNetworkReply *reply = manager->get(QNetworkRequest(url));
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QString filename="INSTALL";
QFile file(filename);
file.open(QIODevice::WriteOnly);
file.write(reply->readAll());
delete reply;


above code works perfect. But i failed to download from a ftp site ,with login/pwd.
ex;
if i changed the
QString url="ftp://username:pwd@mysys.com/filename";
download fails.

but when i paste the same in Browser, i can able to download the file.

what im doing wrong?
how to download a file with username , pwd?

pls guide me

Bala

high_flyer
12th February 2010, 14:43
try QFtp::login().

BalaQT
13th February 2010, 09:53
Thnks highflyer.

i made mistake in path.
i got it working by specifying the ftp://username: pwd@mysys.com/home/usr/filename;
previously ftp://username: pwd@mysys.com/filename; [this url is working well in browser.]
now with /home/usr/filename problem is solved

Thnks for the support
Bala