ShoeLace1291 Posted October 4, 2007 Share Posted October 4, 2007 Ok this is my basic folder setup: localhost/ --myprogram(directory) --functions.php --includes(directory) --join.php --photos(directory) --join.php --themes(directory) --default(directory) --joinform_body.tpl the file 'functions.php' contains a function that copies a file selected from the user's computer with a form('themes/default/joinform_body.tpl'). includes/join.php is the file that is using the copy_photo function. What syntax would I have to use to copy the file to the photos directory? copy( $photoname, "$dir" ) or die("There was an error uploading your photo. Please try again later."); That's my copy function where the directory should be localhost/myprogram/photos. $dir = "/photos"; How would I do that? I tried just plain photos but it says the directory doesn't exist so I'm thinking the script thinks it's includes/photos. Link to comment https://forums.phpfreaks.com/topic/71790-including-file-in-parent-folder/ Share on other sites More sharing options...
MmmVomit Posted October 4, 2007 Share Posted October 4, 2007 To get to a parent directory you use ".." For example in the following file system --mmmvomit +-wwwroot | +-index.php | +-profile.php +-img | +-logo.gif | +-annoyingani.gif | +-lolcat.gif +-error_log.txt +-usernames.txt If I want to access 'error_log.txt' from within 'index.php', I can do it like this. $foo = file("../error_log.txt"); The '..' means "go to the parent directory." Since index.php is in wwwroot, the parent directory is mmmvomit. '../error_log.txt' then translates to '/mmmvomit/error_log.txt'. If I want to get at one of the files in the img folder from within index.php, I would do something like this. <img src="../img/lolcat.gif"> The '..' translates to the parent directory of wwwroot, which is mmmvomit. From there it looks in the img folder, then retrieves lolcat.gif. Link to comment https://forums.phpfreaks.com/topic/71790-including-file-in-parent-folder/#findComment-361706 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.