QT-FTP Upload Error

606 views Asked by At

I'm trying to upload a simple txt file to ftp server but getting "QNetworkReply::ContentOperationNotPermittedError" reply from the server and i think it is about my file hierarchy.

Here is the file order of my ftp server and my qt-ftp configuration :

File Order FTP Information

    QUrl url("f13-preview.125mb.com/www/home/repo/test.txt");
    url.setHost("f13-preview.125mb.com");
    url.setUserName("1896230");
    url.setPassword("mypassword");
    url.setPath("f13-preview.125mb.com/www/home/repo/");
    url.setScheme("ftp");
2

There are 2 answers

3
UndeadDragon On BEST ANSWER

I can't get, why do you use QNetwork instead awesome QFtp module, that provides all necessary for work with ftp?

QFtp *ftp = new QFtp(parent);
ftp->connectToHost("f13-preview.125mb.com");
ftp->login("1896230", "mypassword");

and then use QFtp::put. That's all you need.

0
Ceyhan ILERI On

I've changed the QUrl as below and solved the problem, don'T know why but now i'm struglinng with segmentation fault.

QUrl url("fftp://f13-preview.125mb.com/repo/test.txt");
    if(url.isValid())
    {
        url.setHost("f13-preview.125mb.com");
        url.setUserName("1896230");
        url.setPassword("mypassword");
        url.setScheme("ftp");
        url.setPort(21);
    }