CodeIgniter Forums

Full Version: FTP Class: file_exists() does not work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hi all,

Take a look:

public function cron_download_transaction_data()


        $config['hostname'] = 'ip_addr';
        $config['username'] = 'user_name';
        $config['password'] = 'pass';
        $config['debug'] = TRUE;


        $list = $this->ftp->list_files('/');

        print_r($list); // /file1.csv and /file2.csv show up here

        $files_array = array('/file1.csv', '/file2.csv');

        foreach($files_array as $file)
            $this->ftp->chmod($file, DIR_WRITE_MODE); // WORKS
                if(!$this->ftp->download($file, '/var/www/assets/import/folder1/'.$file, 'ascii', 0775))
                    $details = "ERROR: Could not download $file to local folder ('/var/www/assets/import/folder1/$file').";

                echo "File $file does not exist.";



I am able to CHMOD the files, which proves that they exist (I see the permissions changing), but always get "File X does not exist".

Do standard PHP file commands not work with the FTP class?

All input appreciated.

El Forum

maybe a safe mode issue?

El Forum

PHP file commands are relevant to the local server that PHP is installed on. The FTP class utilizes the ftp_* set of functions.

You can use $this->ftp->list_files() to get a list of current files and see if it is uploaded. Or you can extend the FTP library with additional functionality. If you do the latter, consider contributing those additions to CodeIgniter's Github repo to expand CI.

El Forum

Maybe take a look at this:

Now look at your $files_array, you are adding on an extra forward slash...

Remove the forward slash off of the filename.