Results 1 to 4 of 4

Thread: problem with mkdir() in QFtp

  1. #1
    Join Date
    Jul 2009
    Location
    India
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question problem with mkdir() in QFtp

    Hi,

    I have tried that QFtp example for making a ftp client. It works fine.
    But I am unable to make any directory on the remote server using mkdir().

    Please tell me how to do that.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem with mkdir() in QFtp

    What have you tried, how does your code look like and more important, have you the rights to create a folder at the ftp server?

  3. #3
    Join Date
    Jul 2009
    Location
    India
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: problem with mkdir() in QFtp

    Hi,
    Thanx for replying.

    I am making an application that needs to create a folder on the remote computer using ftp.

    The code I am using is as below -
    ************************************************** ************************************************** ****
    ftpSignupAddress = "ftp://172.17.70.99/pub/casestudy/";

    wftp = new QFtp(this);
    connect(wftp, SIGNAL(commandFinished(int, bool)),this,
    SLOT(wftpCommandFinished(int, bool)));

    QUrl wurl(ftpSignupAddress);
    if (!wurl.isValid() || wurl.scheme().toLower() != QLatin1String("ftp")) {
    wftp->connectToHost(ftpSignupAddress, 21);
    wftp->login();
    } else {
    wftp->connectToHost(wurl.host(), wurl.port(21));

    if (!wurl.userName().isEmpty())
    { wftp->login(QUrl::fromPercentEncoding(wurl.userName().t oLatin1()), wurl.password());
    }
    else
    {wftp->login();
    }
    if (!wurl.path().isEmpty())
    {wftp->cd(wurl.path());
    }
    }

    int b=wftp->rename("user1", "user5");
    qDebug() << "rename : " << b ;
    qDebug() << "rename : " << wurl.path() ;
    int a = wftp->mkdir("user007");
    qDebug() << "mkdir : " << a ;
    }
    }

    ************************************************** ************************************************** ****
    On executing this code :

    qDebug() << "rename : " << b ; ------> gives me an integer value = 4

    qDebug() << "mkdir : " << a ; -----> gives me an integer value = 5

    But still there is no folder renaming of the folder.
    there is no folder named "user007" get created.

    * for the permissions to the ftp server. I am using my own ftp to test this code. And I have given 777 permissions to my /var/ftp/pub folder.
    the command i used is -
    sudo chmod -R 777 /var/ftp/pub

    Please tell me , what else I should do.

  4. #4
    Join Date
    Jul 2009
    Location
    Italy, Pieve Ligure (GE)
    Posts
    55
    Thanks
    7
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with mkdir() in QFtp

    Quote Originally Posted by fatima View Post
    Hi,
    Thanx for replying.

    I am making an application that needs to create a folder on the remote computer using ftp.

    [...]

    Please tell me , what else I should do.
    Hi,

    As you probably know, the QFtp command functions like rename() and mkdir() do nothing by themselves but enqueue that command for asynch execution. So, the int returned by, for instance, wftp->mkdir("user007"); is not a sucess/failure code but the index of that operation in the queue.

    As the first lines in your code show, somewhere else in your code you need to define two private slots:

    Qt Code:
    1. void wftpCommandFinished(int iCommand, bool bError);
    2. void wftpDone(bool bError);
    To copy to clipboard, switch view to plain text mode 

    and connect them to QFtp signals:

    Qt Code:
    1. connect(wftp, SIGNAL(commandFinished(int,bool)), this, SLOT(wftpCommandFinished(int,bool)));
    2. connect(wftp, SIGNAL(done(bool)), this, SLOT(wftpDone(bool)));
    To copy to clipboard, switch view to plain text mode 

    In the wftpCommandFinished() slot code, you may test for error and, if any, get the code and the description of the error with wftp->error() and wftp->errorString(). This may cast more light on the reason of the failure. Same for wftpDone.

    Ciao,

    Miwarre

Similar Threads

  1. deployment problem: msvc++ 2008 Express, Qt 4.4.3
    By vonCZ in forum Qt Programming
    Replies: 7
    Last Post: 10th November 2008, 14:38
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.