ETAN
ETAN

Reputation: 3182

Edit FTP file using PHP?

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.

Upvotes: 1

Views: 1155

Answers (1)

ldiqual
ldiqual

Reputation: 15365

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 !

Upvotes: 2

Related Questions