my4bros Posted June 22, 2009 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 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 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 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 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 Share Posted June 22, 2009 Link to comment Share on other sites More sharing options...
es131245 Posted June 22, 2009 Share Posted June 22, 2009 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);}?> Link to comment Share on other sites More sharing options...
my4bros Posted June 22, 2009 Author 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 Share Posted June 22, 2009 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.