Jump to content

PHP Write funtion


pinky_6548

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...