pinky_6548 Posted January 10, 2006 Share Posted January 10, 2006 Hi,I am new with PHP and I am writing a simple code in PHP that does following: <?$file_name = "something.txt";$file_pointer = fopen($file_name, "w");fwrite($file_pointer, "what you wanna write");fclose($file_pointer);echo "data written to file successfully"; ?> But once i upload this simple funtion gives me error:Warning: fopen(something.txt): failed to open stream: Permission deniedWarning: fwrite(): supplied argument is not a valid stream resource Warning: fclose(): supplied argument is not a valid stream resource And somehow reading from file works very well.Has someone faced this before and can help me.Thanks Link to comment Share on other sites More sharing options...
gsmith Posted January 10, 2006 Share Posted January 10, 2006 Sounds to me like your permissions aren't set right. You probably need to chmod the file you're trying to open. You could try a universal chmod 777 first to see if that works, but you'll probably want to tighten the security a little after confirming that's the problem. Link to comment Share on other sites More sharing options...
Eric Posted January 11, 2006 Share Posted January 11, 2006 I think it will also work with 755Just keep in mind when you deal with fopen fwrite and fclose you want to give the file you're trying to write to premission to allow you to write to it Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now