How down- and upload via ftp



  • I want up- and download files to a ftp-server and scan directories for files and folder. How can I do this ?
    I found in the internet the QFtp but I cannot find this class in the current Qt 5.6 documentation.


  • Moderators

    @Andy314

    QFtp is decrepated, but for compatibility Qt4 based applications you can add QtFtp

    The example is based on QNetworkAccessManager. However, you may use it directly or see how to create your required functionality based on QNetworkAccessManager



  • @koahnig

    The QNetworkAccessManager is only for simple up-/download of files I found out. Or this it not correct?
    It is not possible to scan for files or directories on the sever with it - or is there a way to manage this task.


  • Moderators

    @Andy314

    That is what Qt 5.0 docs say:
    The QFtp and QUrlInfo classes are no longer exported. Use QNetworkAccessManager instead. Programs that require raw FTP or HTTP streams can use the Qt FTP and Qt HTTP compatibility add-on modules that provide the QFtp and QHttp classes as they existed in Qt 4.

    As noted above there is a substitute/example code for QFtp downloadable. I had used this in the past, but downloading files when you already know where they are, it is better to use QNetworkAccessManager directly. The provided module does support all of FTP commands therefore there is also a solution for LIST command.

    Here you can clone directly the QFtp section it comes with an example. At day's end I guess it is matter of taste if you want to continue to use QFtp through not supported code or if you use it as initializer for your own code.



  • Hi @koahnig,
    thank you for your help.
    I dont know the files, thats the main requirement of my project, there fore I must use QtFtp. (Can not really understand why this module is removed from the current Qt version ???)

    I was able to compile it after the correction of a include error. What shall I do with the lot of output files now. Must I integrate this in my Qt current installation ?


  • Moderators

    @Andy314 said:

    I dont know the files, thats the main requirement of my project, there fore I must use QtFtp.

    I do not think that this is absolutely true. Probably your thinking is FTP based, which makes it harder to get the basic idea of QNetworkAccessManager. The downloading mechanism looked strange to me in the beginning as well. Therefore, I had integrated the supplied QFtp module into Qt 5. FTP is basically technology of the 1980's. Command-driven stepping from folder to folder. Listing in between until you have navigated to the place where you had to go. This is emulated within the QFtp for Qt5.
    Anyway the actual need of QFtp is more a philosophic discussion in my opinion.
    @Andy314 said:

    I was able to compile it after the correction of a include error. What shall I do with the lot of output files now. Must I integrate this in my Qt current installation ?

    @koahnig said:

    @Andy314

    QFtp is decrepated, but for compatibility Qt4 based applications you can add QtFtp

    As already given in the first post follow the link and see the few steps.

    The example is based on QNetworkAccessManager. However, you may use it directly or see how to create your required functionality based on QNetworkAccessManager

    Your output should be basically 2 libs and 2 dlls (one for release and debug each). You can add them to your installation if you like.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.