QNetworkAccessManager: How to send data/file from ftp connection
-
I try to send data/file to current directory( folder that I want) from windows to Linux ?
For this Firsltyi I tried to download some file from Linux.
Here is my code:QUrl url("ftp://192.168.100.70/root/coming.txt"); url.setUserName("admin"); url.setPassword("admin"); url.setPort(21); QNetworkRequest request(url); manager=new QNetworkAccessManager(this); reply = manager->get(request); connect(reply, SIGNAL(readyRead()), SLOT(downloadReadyRead())); connect(reply, SIGNAL(finished()), SLOT(downloadFinished())); qDebug()<<reply->readAll();
and secondly I tried Qt's example download manager and tried:
QNetworkRequest request(url); QByteArray applicationUserName = "admin"; QByteArray applicationUserPassword = "admin"; request.setRawHeader("Username",applicationUserName); request.setRawHeader("Password",applicationUserPassword); currentDownload = manager.get(request); connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)), SLOT(downloadProgress(qint64,qint64))); connect(currentDownload, SIGNAL(finished()), SLOT(downloadFinished())); connect(currentDownload, SIGNAL(readyRead()), SLOT(downloadReadyRead()));
But it returns me:
Failed: Logging in to 192.168.100.70 failed: authentication requiredBut when I try to connect from fileZilla with this authentication everything is ok.
Do you have any suggestion to me.
What I really want to do is: I want to upload my files into directories that I want from Windows to Linux by ftp connection (exactly like fileZille, almost same but I want to choose ip and path in my code as a hardcode )I will be plesuare for any help and suggestion.
-
I just setup a local ftp server and tested with the downloadmanager example, setting username and password to the url totally works.
I gotDownloading ftp://admin:admin@127.0.0.1/root/coming.txt... [### ] 0.0 bytes/sec Succeeded. 1/1 files downloaded successfully