Not able to create textFile in server using php - urgent

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sujithks81
Forum Newbie
Posts: 2
Joined: Sun Jul 24, 2011 5:21 am

Not able to create textFile in server using php - urgent

Post by sujithks81 »

Dear friends,
I am doing a php project. I want to create a text file in server from client and writr some data init using php.I used following code.
But it is not able to create the file.

$myFile = "test.txt";
$fh = fopen($myFile, 'w') or die("can't open file...");
$stringData = "New Stuff 1\n";
fwrite($fh, $stringData);
$stringData = "New Stuff 2\n";
fwrite($fh, $stringData);
fclose($fh);


Please share your valuable ideas and thought abt this.It is little urgent.
Thanks
Rakesh
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Not able to create textFile in server using php - urgent

Post by internet-solution »

Have you given the web server write permission to the the folder on the server?
sujithks81
Forum Newbie
Posts: 2
Joined: Sun Jul 24, 2011 5:21 am

Re: Not able to create textFile in server using php - urgent

Post by sujithks81 »

I given like chmod 777 * in that folder.
Is this you mentioned?If not plz guide?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Not able to create textFile in server using php - urgent

Post by califdon »

Insert the following at the top of your PHP code:

Code: Select all

ini_set("display_errors",1);
ERROR_REPORTING(E_ALL);
Post Reply