最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to write files in hosting in admin dashboard?

programmeradmin1浏览0评论

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

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

Share Improve this question edited May 16, 2020 at 12:24 Ooker asked Apr 14, 2020 at 12:29 OokerOoker 3324 silver badges23 bronze badges 6
  • 1 Your host would need an API to access its information, and you would need to write a plugin that uses that API. So you will need to ask your host what is available. It's almost certainly impossible to create a plugin that can interact with any user's host, no matter who they are. – Jacob Peattie Commented Apr 14, 2020 at 14:01
  • thank you. You can make that answer and I'll accept it. But I forget to mention that I just want to modify the folder in which the site is installed. For example, if a plugin can change and update the sitemap, can I manually delete it with some plugins, regardless of my hosting? – Ooker Commented Apr 14, 2020 at 19:34
  • It depends on the file permissions of the account. You can theoretically read and write whatever files you want on the same hosting account, but in an optimally configured WordPress environment, the only place place you can reliably write files with your plugin is the uploads directory. – Jacob Peattie Commented Apr 15, 2020 at 1:06
  • I need to read and write files like that. What resource do I need to know more? – Ooker Commented Apr 15, 2020 at 4:56
  • @JacobPeattie What do you mean by 'Your host would need an API'? PHP can manipulate the file system without problems, if the PHP server has sufficient permissions. – djboris Commented Apr 15, 2020 at 14:21
 |  Show 1 more comment

1 Answer 1

Reset to default 4

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

发布评论

评论列表(0)

  1. 暂无评论