my4bros Posted June 22, 2009 Report Share Posted June 22, 2009 hi sir,i want a php script to create a text file inmy folder,fopen() method is not working ...pls provide create a simple text file via php script Link to comment Share on other sites More sharing options...
Synook Posted June 22, 2009 Report Share Posted June 22, 2009 What is your code? How isn't it working? Are there any error messages? Link to comment Share on other sites More sharing options...
es131245 Posted June 22, 2009 Report Share Posted June 22, 2009 I know 2 ways to create a file....1 fopen("file_path.txt",a+);Read the fopen() manualhttp://ru2.php.net/manual/en/function.fopen.phpa+ for"Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it."2touch(); same as shell =) Link to comment Share on other sites More sharing options...
my4bros Posted June 22, 2009 Author Report Share Posted June 22, 2009 i just pastet his coding<?php$file=fopen("file.txt","a+");?>And run itanf get this errorWarning: fopen(file.txt) [function.fopen]: failed to open stream: Permission denied in /home/abcd/public_html/create.php on line 2How do i solve this pls help me Link to comment Share on other sites More sharing options...
es131245 Posted June 22, 2009 Report Share Posted June 22, 2009 Maybe its because user dont have permision to create files in that folder? Link to comment Share on other sites More sharing options...
es131245 Posted June 22, 2009 Report Share Posted June 22, 2009 (edited) Edited June 22, 2009 by es131245 Link to comment Share on other sites More sharing options...
es131245 Posted June 22, 2009 Report Share Posted June 22, 2009 (edited) Try this and tell us what you get....<?php$file_path="file.txt";function your_code();{//paste here your code here if succeed}function change_mod(){{chmod($file_path, 0755);}if(!$file){touch($file_path) or die("PLZ Allow users to create files in www folder");}$file_open=fopen($file,a) or function change_mod();$file_open=fopen($file,a) or die("Error");fclose($file_open);}?> Edited June 22, 2009 by es131245 Link to comment Share on other sites More sharing options...
my4bros Posted June 22, 2009 Author Report Share Posted June 22, 2009 no its getting somany errors ,please give working code to create this .......i terribly need this Link to comment Share on other sites More sharing options...
boen_robot Posted June 22, 2009 Report Share Posted June 22, 2009 (edited) no its getting somany errors ,please give working code to create this .......i terribly need thisContact your host, and ask them for "writing permissions within the public_html folder" and/or further assistance. Edited June 22, 2009 by boen_robot 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