How to write files in hosting in admin dashboard?

I see that some plugins like Wordfence can write on core folders like wp-includes or wp-admin (if write permission is enable). In case everything is permitted, is there a way to interact with the hosting from admin dashboard only? Assuming this is on the site installation folder only.

See also:
• Is there a way to figure out the way to access hosting if I have admin privilege?
• WordPress file manager plugin that can change file permission? in Software Recommendations

1 Answer
1

You basically have two options:

  1. Use any of the available File Manager plugins for WordPress. Just Google them, literally that phrase I just used.
  2. Implement a custom PHP code in your theme or custom plugin which will utilize any of the PHP functions for manipulating the files. For example, check these:
    • file_get_contents() – For reading files
    • file_put_contents() – For writing files. This will also create a new file if it doesn’t exist.
    • unlink() – For deleting files
    • chmod() – For changing permissions
    • chown() – For changing owner

There are also a ton of functions for more advanced file manipulation in PHP. Check this for reference: Filesystem Functions

Leave a Comment