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.
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?
- The topic ‘How to initialize WP_Filesystem object?’ is closed to new replies.