1

i am new to php.

I am wondering how can i edit a ftp file using php script.

For example: i have "style.css" file in my ftp and i want a PHP to produce a page containing HTML text area and inside it is loaded with "style.css" content(CSS). And there's a SAVE button , when the SAVE button is clicked , php will process it and update the "style.css" to the user's edit.

I am looking around the web for tutorials on this but i'm not in good luck.

I am just hoping someone can guide me or provide me a link to tutorials on this.

Thanks and have a wonderful day.

1
  • you need a html page with a form and a 2 php functions file_get_contents() and file_put_contents(). that should get you started Commented Aug 23, 2011 at 7:05

1 Answer 1

2

You don't need any FTP feature here as you want to edit the CSS that is on your PHP server.

You only need a function to write files, just like file_put_contents():

 $css = $_POST['css'];
 file_put_contents('path/to/css/file.css', $css);

If you want to print your current CSS file:

 echo file_get_contents('path/to/css/file.css');

However, allowing users to write directly in your files can be unsafe. Be carreful !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.