# wp-data-access/5.5.84/WPDataAccess/Drive/WPDA_Local.php

WP Data Access – App Builder for Tables, Forms, Charts, Maps &amp; Dashboards, version 5.5.84. 79 lines.

- Page: https://pluginprobe.com/plugins/wp-data-access/5.5.84/code/WPDataAccess/Drive/WPDA_Local.php
- Raw: https://pluginprobe.com/plugins/wp-data-access/5.5.84/raw/WPDataAccess/Drive/WPDA_Local.php
- Modified: 2026-09-16T18:01:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-data-access/5.5.84/code/WPDataAccess/Drive/WPDA_Local.php#L10-L20`.

```php
<?php

namespace WPDataAccess\Drive {

    use WPDataAccess\WPDA;

    class WPDA_Local extends WPDA_Drive {

        public function __construct( $drive = array(), $enabled = false ) {

            $this->drive_type = 'local';

            parent::__construct( 'local', $drive, $enabled );

        }

        public function authorize( $authorization, $enabled = true ) {

            if ( isset( $authorization['path'] ) ) {
                $this->drive = array(
                    'path' => $authorization['path'],
                );
                $this->enabled = $enabled;
                $this->save();

                return true;
            }

            return false;

        }

        public function refresh_token() {

            return true; // N.A.

        }

        public function connect() {

            return true; // N.A.

        }

        public function close() {

            // N.A.

        }

        public function upload_file( $local_file, $remote_file ) {

            copy( $local_file, $this->drive['path'] . $remote_file );

        }

        public function cleanup( $query, $keep ) {

            $keep_counting = 0;
            $files_sorted  = array();

            $path = '/' === substr( $this->drive['path'], -1 ) ? $this->drive['path'] : $this->drive['path'] . '/';

            foreach ( glob( $path . $query ) as $filename ) {
                array_push( $files_sorted, $filename );
            }
            rsort( $files_sorted );

            foreach ( $files_sorted as $file ) {
                $keep_counting ++;
                if ( $keep_counting > (int) $keep ) {
                    unlink( $file ); // phpcs:ignore
                }
            }

        }
    }

}
```
