Results 1 to 12 of 12

Thread: ftp file upload

  1. #1
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default ftp file upload

    Hi freinds,


    i want some example code for ftp upload in qt5.3.

    can any one help.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: ftp file upload

    can any one help.
    Google can.

    I guess you find it easier to use this forum as your search engine.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    52
    Thanks
    8
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: ftp file upload

    check QFtp ...

  4. #4
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: ftp file upload

    QFtp is not working in Qt5.3...

    in which process can i use

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ftp file upload

    You could try a QNetworkAccessManager::put() operation with an ftp URL.

    Cheers,
    _

  6. #6
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: ftp file upload

    Qt Code:
    1. QNetworkAccessManager *Ftp = new QNetworkAccessManager(this);
    2. QNetworkReply *reply = new QNetworkReply (this);
    3. QUrl url ("ftp://192.168.192.91/test.txt");
    4. url.setUserName(test);
    5. url.setPassword(test);
    6. url.setPort(21);
    7.  
    8.  
    9. QFile *data = new QFile(test.txt);
    10.  
    11. if(!data->open(QIODevice::ReadOnly))
    12. {
    13. qDebug() << "Could not open file to FTP";
    14. QMessageBox::information(this,"FTP ","Could not open file to FTP");
    15. return false;
    16.  
    17. }
    18. else
    19. {
    20. reply = Ftp->put(QNetworkRequest(url),data);
    21. }
    To copy to clipboard, switch view to plain text mode 



    but i getting error like this

    QIODevice::read: device not open
    Error Code: "Unknown error"


    can anybody tell why it is coming and give some solution....
    Last edited by anda_skoa; 6th September 2016 at 17:03. Reason: missing [code] tags

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ftp file upload

    Quote Originally Posted by mouni View Post
    Qt Code:
    1. QNetworkReply *reply = new QNetworkReply (this);
    To copy to clipboard, switch view to plain text mode 
    Any specifc reason why you create a QNetworkReply object here?

    Quote Originally Posted by mouni View Post
    Qt Code:
    1. QUrl url ("ftp://192.168.192.91/test.txt");
    To copy to clipboard, switch view to plain text mode 
    Is that a writable location on the target server?

    Quote Originally Posted by mouni View Post
    but i getting error like this

    QIODevice::read: device not open
    Error Code: "Unknown error"
    When do you get this?

    Cheers,
    _

  8. #8
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: ftp file upload

    no

    it is a writable location on server


    while uploading file error is coming

  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ftp file upload

    Quote Originally Posted by mouni View Post
    it is a writable location on server
    Ok.

    Quote Originally Posted by mouni View Post
    while uploading file error is coming
    So you have connected to the QNetworkReply::error() signal and it is emitted before finished()?

    Where do you close/delete the "data" object? In the slot for QNetworkReply::finished()?

    Maybe try "post" instead of "put".

    Cheers,
    _

  10. #10
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: ftp file upload

    it is showing QIODevice::read: device not open

    but files uploading to server...

    what is problem i am not understanding

  11. #11
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ftp file upload

    Are you maybe calling "read" or "readAll" on the reply object?

    Cheers,
    _

  12. #12
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: ftp file upload

    i am not calling read or readall


    when file is given QIODevice::readonly i given..

    QFile *data = new QFile(test.txt);

    if(!data->open(QIODevice::ReadOnly))
    {
    qDebug() << "Could not open file to FTP";
    QMessageBox::information(this,"FTP ","Could not open file to FTP");
    return ;
    }
    reply = Ftp->put(QNetworkRequest(url),data);

    where data is QFile

    reply is qnetworkreply

    ftp is qnetworkacessmanager...

Similar Threads

  1. Problem in Http file upload
    By dipeshtech in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2011, 09:44
  2. Replies: 1
    Last Post: 21st October 2010, 05:59
  3. Qhttp Upload file
    By danny.lesnik in forum Qt Programming
    Replies: 5
    Last Post: 11th December 2009, 10:02
  4. QNetworkRequest file upload -- please help
    By Runtime Technologies in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2009, 16:55
  5. Replies: 5
    Last Post: 20th January 2009, 15:11

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.