nightkarnation Posted August 9, 2010 Share Posted August 9, 2010 Hey guys! I have the following doubt: I have a php file that does the following alongside with other code not displayed here: $fp = fopen("emails.txt", "w"); It opens a txt file called emails.txt that is in the same folder where the php is saved but how do I tell $fp = fopen("/folderbefore/emails.txt", "w"); ?? In other words, how do I write the path on the script that the emails.txt is located in a previous folder where the php file is located?? Thanks in advance for your help Cheers! Quote Link to comment Share on other sites More sharing options...
xangelo Posted August 9, 2010 Share Posted August 9, 2010 ../ That will take you one level above. Just keep adding them for each directory higher you need to go. Your example would be: $fp = fopen("../emails.txt", "w"); Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 9, 2010 Share Posted August 9, 2010 You can move up on level using ../ $fp = fopen("../emails.txt", "w"); ?? Alternatively use a full path $fp = fopen($_SERVER['DOCUMENT_ROOT'] ."/path/from/root/folder/to/emails.txt", "w"); ?? Quote Link to comment Share on other sites More sharing options...
freeloader Posted August 9, 2010 Share Posted August 9, 2010 So if I understand well you want to go up one level? That would be: $fp = fopen("../emails.txt", "w"); edit: common php problems, looks like I've been beaten to it by these other two Quote Link to comment Share on other sites More sharing options...
nightkarnation Posted August 9, 2010 Author Share Posted August 9, 2010 Awesome! Thanks a lot guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.