Important: Please read the Qt Code of Conduct -

QT5 QNetworkAccessManager does not put File on FTP Server

  • After googling now for a while i still have no clue, why the Code does not work.
    I tried much of the things suggested in forums, but still its not working.

    The problem is, that the QNAM never calls the uploadFinished-Slot. There is no Error too, the Error Slot is also not triggered. There is no Problem opening the file..
    The uploadProgress Slot is not called too.

    As far as i can say, there is a valid QNetworkReply when i call the put function.

    I dont know, its just doing nothing.

    Has anybody a good idea what the problem could be?

    @MainWindow::MainWindow(QWidget parent) :
    ui(new Ui::MainWindow)
    connect(&manager, SIGNAL(finished(QNetworkReply
    )), SLOT(uploadFinished(QNetworkReply*)));

    delete ui;

    void MainWindow::doUpload(const QString &file)
    QUrl url("ftp://server/files/jgevas_FTPTest.txt");

    data = new QFile(file, this);

    if (data->open(QIODevice::ReadOnly)) {
    reply = manager.put(QNetworkRequest(url), data);

    connect(reply, SIGNAL(uploadProgress(qint64, qint64)), SLOT(uploadProgress(qint64, qint64)));

    qDebug() << "Problem";

    void MainWindow::uploadFinished(QNetworkReply *reply)
    qDebug() << "Finished" << reply->error();


    void MainWindow::execute()
    doUpload("data/New Text Document.txt");

    void MainWindow::uploadProgress(qint64 bytesSent, qint64 bytesTotal) {
    qDebug() << "Uploaded " << bytesSent << "of " << bytesTotal;

  • Found the Bug myself... took a long time!
    I can not explain why, but when i uncomment the setPort() statement it works...

  • Sorry for the really late answer,
    but this is obvious:

    you cannot upload an file to ftp on port 25
    because setPort sets the post to connect on
    and not on which port the data should be sent from your computer

    the ftp upload port is 21 not 25
    so just replace the setPort line with:


  • I always get the error that "QIODevice: : read: device not open", when you use the Qt 5.3 .I don't the reason.

Log in to reply