We are facing issues when we are trying to send the file (text/image/exe) to the FTP server.
We have used QFtp functions to put the file onto the server with user authentication. But QFtp is taking huge time to upload the files. Hence we moved to QNetworkAccessManager an have used the put method for uploading.
QNetworkAccessManager::put() returns with a reply and finished is also triggered, but no file is getting uploaded.
I have used the below code to put:
QUrl uploadurl
("ftp://server/dir/");
uploadurl.setUserName("XXXXXX");
uploadurl.setPassword("XXXXXX");
uploadurl.setPort(21);
QNetworkRequest upload(uploadurl);
QNetworkAccessManager *uploadman = new QNetworkAccessManager(this);
if(file
->open
(QFile::ReadOnly)) { uploadman->put(upload, file);
}
QUrl uploadurl("ftp://server/dir/");
uploadurl.setUserName("XXXXXX");
uploadurl.setPassword("XXXXXX");
uploadurl.setPort(21);
QNetworkRequest upload(uploadurl);
QNetworkAccessManager *uploadman = new QNetworkAccessManager(this);
QFile* file = new QFile("filepath");
if(file->open(QFile::ReadOnly)) {
uploadman->put(upload, file);
}
To copy to clipboard, switch view to plain text mode
Please help us out with the above issue. Any example code would be a great help.
Thanks in advance.
Bookmarks