Link to home
Start Free TrialLog in
Avatar of ramrocket
ramrocket

asked on

Why can't I FOPEN a file?

I just want to do a simple write i/o:

$filename="testdata.txt";
$fp =fopen($filename, "w") or die("Error opening file");
fwrite($fp,'this is a test');
fclose($fp);

I get this error PHP4:

Warning: fopen(testdata.txt): failed to open stream: HTTP wrapper does not support writeable connections.

thanks in advance
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

Odd.  Looks like PHP decided that testdata.txt was a path using http, rather than using your local file system.  Try prepending the file:// wrapper:
$filename = "file://testdata.txt";
Avatar of ramrocket
ramrocket

ASKER

I tried:

1. $filename=$_SERVER['DOCUMENT_ROOT'] . '/latlon_web/data/testdata.txt';

2. $filename= "file://testdata.txt";

no luck.
ASKER CERTIFIED SOLUTION
Avatar of TeRReF
TeRReF
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial