Re: Setting paths in PHP
| From: | (Miles Thompson) | Date: | Thu, 10 May 2001 20:05:53 +0000 |
| Subject: | Re: Setting paths in PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-52344@lists.php.net to get a copy of this message | ||
Johan,
Use a combination of getcwd() and chdir(). It's well worth while checking out the functions offered for both directory and file.
<?
$cwd = getcwd();
chdir ($cwd."/wherever/you/want/to/set/it");
#The following index.htm contains links, see below. $link = "data/data.htm"; $fd = fopen ($link, "r"); echo fread ($fd,filesize( $link)); fclose ($fd);
chdir( $cwd );?> Cheers - Miles Thompson At 10:07 PM 5/10/01 +0200, Johan wrote:
My question: how do you set a path using php or html? I need it for the following code: index.php ----------------------------------------- <?#The following index.htm contains links, see below. $link = "data/data.htm"; $fd = fopen ($link, "r"); echo fread ($fd,filesize( $link)); fclose ($fd);?> --------------------------------------------------- data.htm ------------------------------------------ <download.htm>Download it now! --------------------------------------------------- The PHP includes the data.htm file in the page generated by index.php, but the link DOWNLOAD.ZIP won't work because that file is in the DATA directory. How can I set the path to DATA - and after reading the file, set the path back to the directory where index.php is located? I'm running Linux.Thanks in advance, Johan-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net