FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


i cannot open a file with fopen()





cihan
my zzz.php is:
Code:
<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>

when i execute it, it gives this:
Code:

Warning: fopen(test.txt) [function.fopen]: failed to open stream: Permission denied in /home/cihan/domains/baglantilarim.com/public_html/zzz.php on line 2

Warning: fwrite(): supplied argument is not a valid stream resource in /home/cihan/domains/baglantilarim.com/public_html/zzz.php on line 3

Warning: fclose(): supplied argument is not a valid stream resource in /home/cihan/domains/baglantilarim.com/public_html/zzz.php on line 4

i changed zzz.php permission to 755. nothing happened...

as far as i remember i had no problem about creating files in the past. I had created a .txt file with no problem. but now this error stopped me...
m-productions
the problem is (I think...at least this is the crap of a problem im having)

You own that file, and Apache (the script) is trying to read the file, thus, it is a "guest" you need to set the file to 777.
SpellcasterDX
I believe the permission has to be set at the highest: 777.
cihan
thank you for answers but unfortunately nothing changed when i set it to 777. Still the same error...
SpellcasterDX
Code:
<?php
$file = test.txt
$handle = fopen($file, "rb");
$testfile = fread($handle, filesize($file));
fclose($handle);
$out = fopen("test.txt", "w");
fwrite($out, $testfile);
fclose($out);
?>



Umm I just pieced this together from an fopen and fclose file I have that's made for forums.
m-productions
ok, the file and the folder both need to be 777
cihan
thanks m-productions.
i changed also the folder's permission to 777. It worked!
Related topics
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.