Overwrite a file with the content of a textarea

I’ve tried to solve my problem all day now and hopefully someone can help me here.

This is my goal:
Beeing able to edit and save files located in the uploads directory (for example wp-content/uploads/myplugin/style.css).

I already managed to create a site with a textarea that contains the code from the style.css.
I did it this way:

<textarea><?php include([dynamic_path_to_file]) ?></textarea>

This is working fine.
I also managed to integrate the codemirror-editor which is looking and working really nice.

Now I want to save the file after editing its content.

How can I do that?

I already tried some AJAX-Functions, for example as it is explained here:
https://stackoverflow.com/questions/9543224/how-to-sending-php-code-from-codemirror-editor-via-jquery-ajaxpost-and-using-p

I was also thinking of something like putting it in a form and send it somewhere on submit but I did not manage to get any good result.

If you can help me with my problem you’d really make my day.

Thank you in advance, Oliver!

Read more here:: Overwrite a file with the content of a textarea

Leave a Reply

Your email address will not be published. Required fields are marked *