PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 19th, 2002, 06:04 PM
KingGiff KingGiff is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 KingGiff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to KingGiff
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!

Reply With Quote
  #2  
Old May 19th, 2002, 08:05 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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....

Reply With Quote
  #3  
Old May 21st, 2002, 08:17 PM
greggory greggory is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Reims, France
Posts: 82 greggory User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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. . ...

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Opening a file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway