• Resolved n381

    (@n381)


    Hello, recently i’ve been considering WP’s built-in FTP functionality for the purpose of remote uploading images from media library to the CDN service with a limited WP integration.

    I’ve found about WP configs constants definitions that are supporting ‘FTP_CONTENT_DIR’ and ‘FTP_PLUGINS_DIR’ and so tried to define ‘FTP_UPLOADS’
    by adding a new constant definition into:
    wp-admin/includes/class-wp-filesystem-base.php

    public function find_folder( $folder ) {
    --
        if ( stripos( $this->method, 'ftp' ) !== false ) {
            $constant_overrides = array(
                'FTP_BASE'        => ABSPATH,
                'FTP_CONTENT_DIR' => WP_CONTENT_DIR,
                'FTP_PLUGIN_DIR'  => WP_PLUGIN_DIR,
                'FTP_UPLOADS'    => WP_UPLOAD_DIR,
    

    Afterwards i’ve set the wp-config.php:

    //FTP
    define('FS_METHOD', 'direct');
    
    define('FTP_BASE', '/export/home/123-user/htdocs/uploads/');
    //define('FTP_CONTENT_DIR', '/export/home/123-user/htdocs/');
    
    define('FTP_UPLOADS', '/export/home/123-user/htdocs/uploads/');
    //define('UPLOADS', 'uploads');
    
    define('FTP_USER', '123-user');
    define('FTP_PASS', 'password123');
    define('FTP_HOST', '123-user.server.co');
    
    /* That's all, stop editing! Happy publishing. */

    No server errors but also no files transferred with the above customization.

    Is there possibility that above technique could work with your plugin SSH SFTP Updater Support?
    Any advice on this subject really appreciated, thank you regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author David Anderson

    (@davidanderson)

    Unfortunately I have no idea – I’ve never tried something like that; the only real way to find out would be to test it and see what happens.

    David

    Thread Starter n381

    (@n381)

    Ok understand, this plugin is to enable SFTP at WP without any further configuration.

    Adding for reference how i’ve tested:

    //SFTP
    define('FS_METHOD', 'ssh2');
    
    define('FTP_BASE', 'sftp://[email protected]:2200/export/home/123-user/htdocs');
    define('FTP_CONTENT_DIR', '/export/home/123-user/htdocs/');
    define('FTP_UPLOADS', 'sftp://[email protected]:2200/export/home/123-user/htdocs/uploads');
    
    //define('UPLOADS', 'uploads');
    define('FTP_USER', '123-user');
    define('FTP_PASS', '123password');
    define('FTP_HOST', '123server.co');
    
    /* That's all, stop editing! Happy publishing. */

    `

    Would be thankful for any further information on this WP SFTP – remote uploading configuration,
    regards.

    • This reply was modified 2 years, 2 months ago by n381.
    Plugin Author David Anderson

    (@davidanderson)

    Sorry – I should have remembered earlier, but now you’ve triggered my memory. WordPress has no provision for sending uploads (i.e. media, stuff that goes in wp-content/uploads by default) over network filesystems. It can only save it locally. That wp-content/uploads is immediately writeable by the webserver is required for a valid WP install. This plugin plugs into WP’s filesystem layer, but WP won’t ever use that layer for uploads/media, so there’s nothing you can configure for that folder anywhere.

    David

    Thread Starter n381

    (@n381)

    Thank you for the response,

    yet there is define('FTP_CONTENT_DIR', '/export/home/123-user/htdocs/wp-content');
    that suppose to take over entire ‘wp-content’ directory including ‘uploads’ is that way suppose to?

    • This reply was modified 2 years, 2 months ago by n381.
    Plugin Author David Anderson

    (@davidanderson)

    That constant isn’t used by WP for uploads. Some plugins create their own folders inside the content directory, and it’s used for that.

    David

    Thread Starter n381

    (@n381)

    Thanks for clarifying, regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘regarding FTP and SFTP within WP’ is closed to new replies.