I've got a problem with programming an easy FTP-Upload in QT. I am currently using QT 5.5 and the QFtp Class is no longer available. So I used the code that is working in my Visual C++ project.
Is there a way I can fix this problem? Is it possible to get QFtp working in QT 5.5?
(string fileToUpload is the file path)
(string fileName is the name of the file on the remote machine when it is uploaded)
Thanks in advance!
As stated in the Qt 5.4 documentation, there are add-ons that provide FTP and HTTP streams:
However, I suggest you start using QNetworkManager to do your FTP & HTTP access. Its interface is more complex (essentially all requests are handled asynchronuously) but when you get the hang of it, it's not so difficult.
Your compilation error is related to conversion of const char*
to const wchar_t*
. If you are satisfied with FtpPutFileW
you can just convert file name to wchar_t*
. That can be done using Qt QString
: QString::toWCharArray(wchar_t * array)
to convert the string to wchar_t
array (this function does not append null character) or using direct cast:
reinterpret_cast<const wchar_t *>(qstring.utf16())
Also it possible to use various approaches to conversion of std::string
to wchar_t*
.
If you need just FTP put
operation the QNetworkManager
has such function. However, QNetworkManager
has limited support for low level FTP: https://stackoverflow.com/a/32568786/4023446
So, for other low level FTP commands it is possible to install manually Qt FTP
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.