Editing Files with Php

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
Forlorn
Forum Newbie
Posts: 5
Joined: Mon May 26, 2003 12:57 am

Editing Files with Php

Post by Forlorn »

I have a problem, I want to allow users to edit txt files on the server but I can't find a command to do that via php. I know I can write to files and read them but what if the user wants to remove things from the file. I want the user to have full control of the file. They should be able to edit everything in a textbox and just click sumbit for the changes to take effect. I can't seem to figure out how to do that however. Can someone please help me :) ?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

I think, that some solution may by putting everything from the file to a textarea in html form. Then after the user's correction, the whole new content will be write to that file, erasing existing data. That's the simplest thing to do, I think :D
User avatar
coolpravin
Forum Newbie
Posts: 20
Joined: Mon May 19, 2003 12:56 am
Location: India

Post by coolpravin »

Try to use fread and fwrite.
If you want to replace origianl content
then fopen is the best solution for you.
Check it in manual
fopen
fopen
(PHP 3 <= 3.0.18, PHP 4 >= 4.0.0)

fopen -- Opens file or URL
Description

Code: Select all

<?php

int fopen (string filename, string mode [, int use_include_path])

?>
Forlorn
Forum Newbie
Posts: 5
Joined: Mon May 26, 2003 12:57 am

Post by Forlorn »

Thanks Delorian, I can't believe I didn't think of that :(
Post Reply