-
File Operation
Hi,
Please tell me what's wrong with the following snippet of code.
[phpcode]
<?php
$total=100;
$a=fopen("Thankyou.txt","w");
fwrite($a,$total);
fclose($a);
?>
[/phpcode]
I have got the following error messages:
Warning: fopen(Thankyou.txt): failed to open stream: Permission denied in /home/amitnet/public_html/test.php on line 4
Warning: fwrite(): supplied argument is not a valid stream resource in /home/amitnet/public_html/test.php on line 5
Warning: fclose(): supplied argument is not a valid stream resource in /home/amitnet/public_html/test.php on line 6
Please help.
Thank you very much for help in advance.
-
Re: File Operation
make sure you have write permissions to the file Thankyou.txt. I assume you have shared webhosting on a *nix server.. so, just FTP into your server and right click on your Thankyou.txt file, and chmod it so that you have write permissions. If you don't know how, with most FTP clients you can right click on a file and either go to "Properties" or something that says permissions, CHMOD, or anything similar.. most FTP clients then ust give you 9 checkboxes, 3 for read, 3 for write, and 3 for execute. since your text file is not executable, you can leave the execute ones blank. you can check the 3 read and 3 write ones.
this should rectify your problems.
-
Re: File Operation
Thank you for your help.
Please tell me how to set file attributes from php code.
-
Re: File Operation
You can't. Not from PHP. You must do it from the FTP client.