ENM185
ENM185

Reputation: 47

How to I use file_put_contents() to place content in a file inside a different directory?

I have a form inside of a file on my website. This file is in a directory called "blog", but I want my file_put_contents to go to the home page on my website. Here is what I have:

file_put_contents("enm185.tk/index.php","example code")

This is inside my file, which is at enm185.tk/blog/index.php. Is there any way to get this to work?

Upvotes: 1

Views: 57

Answers (1)

George Brighton
George Brighton

Reputation: 5151

You can either use an absolute path, or .. to go up a directory:

file_put_contents('../index.php', 'example code');

Upvotes: 3

Related Questions