3

I have projects that have to use FTP for file transfers. And all the projects are created with Qt 6.0.2.

The problem is, I can't upload any files to my FTP server. I tried it with Qt 5.15.2 and it all works fine, but whatever I try, I just couldn't success it with the Qt 6.0.2 version.

The error message is:

Protocol "ftp" is unknown

I researched all of the Qt documents, but I couldn't find any information about it.

Here is my code (working well with 5.15.2):

manager = new QNetworkAccessManager(this);

ftpAddress = "ftp://xxxx.net/";
ftpPort = 21;
username = "xxx";
password = "xxx";

QUrl ftpPath;
ftpPath.setUrl(ftpAddress);
ftpPath.setUserName(username);
ftpPath.setPassword(password);
ftpPath.setPort(ftpPort);

QNetworkRequest request;
request.setUrl(ftpPath);

downloadFileListReply = manager->get(request);
connect(downloadFileListReply, SIGNAL(finished()), this, SLOT(downloadFileListFinished()));

And a picture of the message box:

image

ka ra
  • 31
  • 3

3 Answers3

3

According to this blog post:

With Qt 6 we planned to move the ftp backend out of Qt Network and to distribute it separately as a plugin.

Now, it's not obvious where to get that plugin or how to load it, but there is some sample FTP client code here:

https://doc-snapshots.qt.io/qt6-dev/qtscxml-ftpclient-example.html

I found all this information via Google.

Paul Sanders
  • 24,133
  • 4
  • 26
  • 48
0

This post is a few months old, but the problem is still the same.
I have been using Qt for a short time and chose to use a recent version like Qt 6.4.2. And I faced the same problem. "Protocol 'ftp' is unknown"

To find out if the protocol is supported, just use the following code:

manager = new QNetworkAccessManager(this);
qDebug() << manager->supportedSchemes();

Under QT 5.15.2 it gives this

("ftp", "file", "qrc", "http", "https", "data")

Provided that you have copied the DDL files "libcrypto-1_1..." and "libssl-1_1..." in the folder of your executable otherwise the https does not appear.

And under QT 6.4.2 it gives this

QList("file", "qrc", "http", "https", "data")

And all the articles I've read clearly state that the FTP protocol is no longer natively supported by QT6.
Not enough user requests requesting the FTP protocol, so no development planned.

The solution seems to use libcurl lib curl wrapper

hope this information can help.

Juan
  • 690
  • 4
  • 15
0

The FtpClientCpp library https://github.com/embeddedmz/ftpclient-cpp (which I just found) seems to have a nicer API than libcurl or its C++ wrapper.

David Faure
  • 1,836
  • 15
  • 19