Downloading files over FTP

Downloading a file over FTP is as simple as downloading files over HTTP. If it is an anonymous FTP server for which you do not need an authentication, just use the URL as we did before. Assuming that there is again a file called version.txt on the FTP server on the localhost, type this:

m_network_manager->get(QNetworkRequest(    QUrl("ftp://localhost/version.txt"))); 

That's all; everything else stays the same. If the FTP server requires an authentication, you'll get an error; consider this example:

Likewise, setting the username and password to access an FTP server is easy—either write it in the URL, or use the setUserName() ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.