WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to initialize WP_Filesystem object? (2 posts)

  1. fhsm
    Member
    Posted 3 years ago #

    I'm trying to use the the wordpress file system abstraction class in a plugin. I can't figure out what I'm supposed to pass in to WP_Filesystem to correctly initialize it.

    WordPress(Apache) has write privilege for my uploads dir so it should be able to use direct file system access; however, I've found that in my plugin the wp_filesystem is trying to use the FTP 'driver'. If I add define('FS_METHOD', 'direct'); before calling WP_Filesystem(); and force the direct fs access driver I'm able to use WP_Filesystem as expected.

    I've tried WP_Filesystem(array(), 'path/to/my/uploads/dir'); which doesn't work even though I can write to that path from php in my plugin. Clearly I'm not understanding how get_filesystem_method works when called by WP_Filesystem.

    I don't want to use FS_METHOD define to force wp_filesystem to the correct driver (for my particular server) as a long term solution. (TL;DR)So what should I be passing for $args and $context to WP_Filesystem to allow the auto detection by get_filesystem_method to work?

  2. fhsm
    Member
    Posted 3 years ago #

    Sorry I double posted somehow please see use: http://wordpress.org/support/topic/how-to-initialize-wp_filesystem-object

    Can a mod delete this one or someone tell me how to delete this one to avoid confusion.

    Thx.

Topic Closed

This topic has been closed to new replies.

About this Topic