Results 1 to 3 of 3

Thread: Download File

  1. #1
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Download File

    hi,
    im using qt4.5.2 in debian. i want to download a file from web.
    so i used the following code
    Qt Code:
    1. QNetworkAccessManager *manager=new QNetworkAccessManager;
    2. QString url="ftp://ftp.trolltech.com/qt/source/INSTALL";
    3. QNetworkReply *reply = manager->get(QNetworkRequest(url));
    4. QEventLoop loop;
    5. connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    6. loop.exec();
    7. QString filename="INSTALL";
    8. QFile file(filename);
    9. file.open(QIODevice::WriteOnly);
    10. file.write(reply->readAll());
    11. delete reply;
    To copy to clipboard, switch view to plain text mode 

    above code works perfect. But i failed to download from a ftp site ,with login/pwd.
    ex;
    if i changed the
    Qt Code:
    1. QString url="ftp://username:pwd@mysys.com/filename";
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by BalaQT; 12th February 2010 at 15:36.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Download File

    try QFtp::login().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Download File

    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
    Last edited by BalaQT; 13th February 2010 at 11:35.

Similar Threads

  1. Replies: 1
    Last Post: 16th September 2009, 11:59
  2. NEED HELP: How to download file without breaking function
    By codeslicer in forum Qt Programming
    Replies: 10
    Last Post: 22nd April 2008, 05:10
  3. How to download any file through ftp server
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2007, 02:23
  4. QHttp download file problem.
    By fengtian.we in forum Qt Programming
    Replies: 12
    Last Post: 12th June 2007, 10:39
  5. QHTTP problem,download multi-file.
    By fengtian.we in forum Qt Programming
    Replies: 6
    Last Post: 28th May 2007, 07:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.