php function ftp_delete not deleting anything

Discussion in 'Installation/Configuration' started by Hans, Sep 28, 2010.

  1. Hans

    Hans Moderator Moderator

    It seems that files within the web folder can't be deleted via the php ftp_delete function, like this: ftp_delete ( resource $ftp_stream , string $path )

    The server is a Debian Lenny server with ISPConfig3 and PureFTP
    php5-fastcgi and suEXEC are enabled for the web.

    Is there a solution for this, so it is possible?

    Thanks for your help in advance!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

  3. Hans

    Hans Moderator Moderator

    Hi Till,

    Yes files can be deleted with a FTP-client like FileZilla.
    I will enable debugging to see what happens.
     
  4. Hans

    Hans Moderator Moderator

    O, i forgot to mention: Within the browser when i execute the phpfile, i got the following error:

    Code:
    Warning: ftp_delete() [function.ftp-delete]: Could not delete /web/foo/filename.ext: Operation not permitted in /var/www/clients/clientXXwebXX/web/filename.php on line XX
    When i enable debugging in PureFTPd, i see the follwowing lines appearing in the /var/log/syslog:

    Code:
    Sep 28 16:13:27 xen1 pure-ftpd: ([email protected]) [INFO] New connection from 127.0.0.1
    Sep 28 16:13:27 hostname pure-ftpd: ([email protected]) [DEBUG] Command [user] [username]
    Sep 28 16:13:27 hostname pure-ftpd: ([email protected]) [DEBUG] Command [pass] [<*>]
    Sep 28 16:13:27 hostname pure-ftpd: ([email protected]) [INFO] username is now logged in
    Sep 28 16:13:27 hostname pure-ftpd: ([email protected]) [DEBUG] Command [cwd] [/web]
    Sep 28 16:13:27 hostname pure-ftpd: ([email protected]) [DEBUG] Command [dele] [/web/filename.ext]
    Sep 28 16:13:27 hostname pure-ftpd: ([email protected]) [INFO] Logout.
     
    Last edited: Sep 28, 2010
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    The problem might be the / at the beginning as it can be that the ftp server interperts it as absolute path and not relative path.

    Try to delete the file by using the path "web/filename.ext" or just "filename.ext" as there seem to be a "cd" executed before the delete.
     
  6. Hans

    Hans Moderator Moderator

    @Till,
    Weird, no result yet.
    This is a part of the code used within the phpfile:

    Code:
    <?php
    
    // ftp constants
    define('FTP_USE_FTP', TRUE);
    define('FTP_HOST',    'localhost');
    define('FTP_PORT',    '21');
    define('FTP_TIMEOUT', '20');
    define('FTP_PASSIVE', FALSE); /* */
    define('FTP_SSL',     FALSE);
    
    // LIVE settings
    define('FTP_USER',    'username');
    define('FTP_PASS',    'pasword');
    define('FTP_PATH_TO_ROOT', '/web');
    
    $ftp_stream = ftp_connect(FTP_HOST, FTP_PORT, FTP_TIMEOUT);
    
    ftp_login($ftp_stream, FTP_USER, FTP_PASS);
    
    // set transfer mode
    ftp_pasv($ftp_stream, FTP_PASSIVE);
    
    // set current directory to root of site
    ftp_chdir($ftp_stream, FTP_PATH_TO_ROOT);
    
    $file = '/stage/cms/../uploads/images/filename.ext';
    
    [COLOR="Red"]ftp_delete($ftp_stream, FTP_PATH_TO_ROOT . $file);[/COLOR]
    
    exit;
    Any idea what is wrong then here?
    (The red line gives the error in the browser)
     
  7. Hans

    Hans Moderator Moderator

    @Till,
    Probably it has something to do with the path name indeed, but whatever i do i can't get it to work!
    Is anyone able to test if the php_delete function is able to its work on an ISPconfig3 server?

    Thanks in advance!
     

Share This Page