OK, you don't understand it. Maybe you learn it in this way:
Start -> run -> cmd.exe
Now you have the command line open type this command:
- Code: Select all
c:
cd \
Now the Command will look like this:
- Code: Select all
C:\>
Now you follow your Path from the code, type:
- Code: Select all
cd C:\xampp\htdocs\..\
Now you will not be in the folder htdocs, you will be in the folder xampp. And THERE(!) the orders.txt will be created!
In your second code you try to create the file in the subdirectory files, try it in the Console:
- Code: Select all
cd C:\xampp\htdocs\..\files\
You will get an error, saying the system can not find the path. Thats correct, because you want to open C:\xampp\files, and this folder is not existing. PHP can only create files with the fopen command, directorys are not created. That's the reason why the second code is not working!
Your problem all the way through this post are just the two dots:
- Code: Select all
$fp = fopen ("$DOCUMENT_ROOT/../files/orderts.txt", 'w') ;
Replace it with this code:
- Code: Select all
$fp = fopen ("$DOCUMENT_ROOT/files/orderts.txt", 'w') ;
and everything should be fine. But it is very important that you understand why it is working now, otherwise you will have problems all the time.
glitzi