how to change the mode of text file

wxdqz

New Member
Dears

I write a php program for a counter and store the record to the text file. However, writing the text file is not allowed, I try to change the mode by

chmod("../image/counter.txt",0777);

But fails. Please give some advice, thanks

Sincerely yours,
Simon

Below is the code for the counter



<?
if (session_is_registered(count)==false){
if(!$fp=fopen("../image/counter.txt","r")){
$count=100;
}else{
$count=fgets($fp,10);
$count=$count+1;
fclose($fp);
session_register(count);
}
}

$len=strlen($count);

for($i=1;$i<=6-$len;$i++)
{
$imagpath.="<img src=http://www.phpbuilder.com/board/archive/index.php/../image//0.gif>" ;
}
chmod("../image/counter.txt",0777);
for($i=1;$i<=$len;$i++)
{
$imagpath.="<img src= ../image/".substr($count,$i-1,1).".gif>";
$fp=0;

$fp=fopen("../image/counter.txt","w+");
$rc=fputs($fp,$count,strlen($count)+1);
fclose($fp);

}
?>
 
Back
Top