|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Opening a file
Hello everyone,
I just found your site through the coding contest, but I had a question so I thought I'd test you all out What I'm doing is opening a file and saving it's contents to a string, using the following code: Code:
join('',file($access));
In this case, the access variable is Code:
$access = $path.'/'.$filename; However, the problem I'm running into is getting it read the file. The path variable is set to the path off the web server (the virtual path), so if you had an address like: http://www.somewhere.com/the/place/file.html, the path variable would be 'the/place' and so the access variable would be 'the/place/file.html'. Now, I've realized that you have to change the directory to the root directory, so before I attempt to open the file, I have this code: Code:
chdir($HTTP_ENV_VARS['DOCUMENT_ROOT']); So, I'm thinking this should work, because it worked when I did a is_dir check on the path directory (to make sure it was existant), but, I'm not sure why it won't read the file correctly. If anyone has any suggestions, please let me know, thank you! |
|
#2
|
|||
|
|||
|
RE: Opening a file
Hmm..when I try and use $HTTP_ENV_VARS['DOCUMENT_ROOT'] in my scripts, I don't get anything (this is with apache). If I use $DOCUMENT_ROOT or $_SERVER['DOCUMENT_ROOT'] I get the desired result....
|
|
#3
|
|||
|
|||
|
RE: Opening a file
Sometimes, join() doesn't read the file correctly. So I use fopen() and fread() when I have a file to read.
But, I still have to know the full file name. . ... |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Opening a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|