write a text file using PHP to a specific URL of the same server


I have a php script that writes a text file to the same directory where the script is.
Now the problem is, the script gets a URL from some other script. Now the new text file is supposed to be written to this provided location from the last step.
The provided location is in URL format: "www.example.com/main/foo/"

Is there a way to write a text file to this particular folder? I am writing from the same machine so I assume it shouldn't be really difficult? thanks for any help cheers Ali

Flexi Comment Box

I think righting with the most basic fopen function would be the best way. And instead of using absolute path, you should choose relative paths. With fopen you may want to use 'a' for append instead of 'w' for write.
here is the syntax:

$fp = fopen('data.txt', 'a');

have fun!