Forum Moderators: coopster

Message Too Old, No Replies

using $document_root with fopen

using $document_root with fopen

         

xray012

12:13 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



Hello again,

This is the second question i (still) have, not sure if thats permitted?

Ime trying to update a file: /updates/updates.txt , from /modify/modified.php

finding the root is my problem,
i cant use phpinfo() on my site, so had to call them for my path: something like this: ext/m/mysite/html

i've tried;

fopen("/ext/m/mysite/html/updates/updates.txt","r+")
fopen($_SERVER["document_root"]."updates/updates.txt","r+")

and some variations on these, the root_path problem is often discussed on the net, but mainly for include :S

thnx again!

daisho

4:37 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



Are you on windows? If so there is no "DOCUMENT_ROOT" environment variable as this is an apache thing.

Though your code will still now work as DOCUMENT_ROOT does not have a trailing slash and is uppercase.

Ie:

fopen($_SERVER["document_root"]."updates/updates.txt","r+")

should be

fopen($_SERVER["DOCUMENT_ROOT"]."/updates/updates.txt","r+")

daisho.

jamie

4:41 pm on Dec 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi xray

try using all caps $_SERVER['DOCUMENT_ROOT']

and try uploading a simple page with

<?php

echo $_SERVER['DOCUMENT_ROOT'];

?>

to see if it looks ok

good luck

<added> too slow ;)

xray012

7:47 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



hi, thanx for your help...

sorry for not capping my document_root :S

when i do: echo $_SERVER['DOCUMENT_ROOT']
the echo = /ext/default

i tried applying this like below;

fopen($_SERVER['DOCUMENT_ROOT']."/m/mysite/html/update/updates.txt"."r");

Again, No Go?

[edited by: xray012 at 8:09 pm (utc) on Dec. 16, 2003]

jatar_k

7:50 pm on Dec 16, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



is this the proper path to the doc?

/ext/default/m/mysite/html/update/updates.txt

and when you say, no go, did you get an error message? What specifically happened?

xray012

8:13 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



Hello,

since phpinfo didn't work i had to call my isp, the full path to the root should be:
/ext/m/mysite/html

the doc_root echo resulted: ext/default?

after trying various variations, i got a error report once, in this report i saw a complete different path someting like this: /mnt/..and..then..some

i'me totaly confused?!

xray012

8:51 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



k, managed to get a error-report;

<?php

$upd = fopen($_SERVER['DOCUMENT_ROOT']."/m/my-site/html/update/new-updates.txt","r+");

$output2="$datum¦data¦data";

echo "upd = $upd" ;

fwrite($handle2, $output2);

?>
resulted in:

Warning: fopen(): open_basedir restriction in effect. File(/ext/default/m/my-site/html/update/new-updates.txt) is not within the allowed path(s): (.) in /mnt/storage2/m/my-site.nl/html/pics/foto-install.php

the attributes on the update folder: 755
the attributes on the new-updates.txt: 766

[ i know:handle2 should be upd ;) ]

?in the error-path ".nl" suddenly appears , could this be a totaly different path?

ive also tried applying it to the code above.

even more confused!!?

bcolflesh

8:55 pm on Dec 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Safe mode is on - move the .txt into the directory you are calling fopen() from.

xray012

9:09 pm on Dec 16, 2003 (gmt 0)

10+ Year Member



THANX Thanx Thanx , i was becomming frustrated ;)

So my efforts where blocked by a Safe Mode setting,

-it wouldn't be wise for me to ask to change this setting, if possible?

Thanks Again