PDA

View Full Version : FTP Upload using QNetworkAccessManager



replax
3rd March 2011, 10:41
Hello,

Currently, I am trying to write a program which should upload a file to an FTP server. As recommended in the QT Docu., I chose to use QNetworkAccessManager's put function instead of QFtp. As far as I know, I should be able to access the FTP Server without using any security measures.


QUrl uploadurl("ftp://ftp.drivehq.com/wwwhome/");
uploadurl.setUserName("XXXXXX");
uploadurl.setPassword("XXXXXX");
uploadurl.setPort(21);
QNetworkRequest upload(uploadurl);
QNetworkAccessManager *uploadman = new QNetworkAccessManager(this);
uploadman->put(upload, file);


Basically, this is the code which should perform the upload.
However, the file will not show up on the server. The file is about 1-2kb "big", and is opened as ReadWrite.
Has anybody got an idea what I am doing wrong?

Thank you for your time!

cheers
replax

ChrisW67
3rd March 2011, 10:50
Could be almost anything. If you didn't discard the QNetworkReply* returned by QNetworkAccessManager::put() you could look at its QNetworkReply::error() for some insight.

beemaneni
30th October 2014, 13:32
This thread is expired i feel.just this update is for users to know..
change 1st line to;
QUrl uploadurl("ftp://ftp.drivehq.com/wwwhome/xxxx");