Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6663615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:31:07+00:00 2026-05-26T02:31:07+00:00

Is there any existing php code that will allow me to edit and save

  • 0

Is there any existing php code that will allow me to edit and save files from the browser?

Ex: a text area on the page site.com/edit.php would save to a specified file? I want to be able to edit files on the fly.

I am hosting the site on XAMPP and cant seem to get FTP working so this would be a big use if I need to edit a file and cant get access to the hosting computer.

This is the closest I have found to what I need, however cant seem to get it to work (the goal is to change ‘change.php’):

<?php
  if ($changefile) {
     $slash = stripslashes($_POST['filetest']);
     $filetochange = "change.php";
     $filetochangeOpen = fopen($filetochange,"w") or die ("Error editing.");
     fputs($filetochangeOpen,$slash);
     fclose($filetochangeOpen) or die ("Error Closing File!");
     }
?>
<form method=post action="">

<textarea rows="40" cols="60" name="filetest">
<?
// Implode CSS
$filetochange = "change.php";
print (implode("",file($filetochange)));
?>
</textarea><br />

<br />
<input type="submit" value="Change File" name="changefile">
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:31:08+00:00Added an answer on May 26, 2026 at 2:31 am

    www-data has to have write permission for the files or it won’t work. Be careful with this. Either limit access to your own IPs (as you said) or put in a password protected folder with SSL.

    <?php
    
    $file = $_POST['file'];
    $script = $_POST['script'];
          if($file&&$script) {
          $fp=fopen($file, "w");
          fwrite($fp,$script);
          fclose($fp);
       }
    ?>
    <form method="post">
    <?php
       if($file) {
    ?>
    <textarea style="height: 90%; width: 100%;" name="script">
    <?php
       $fp=fopen($file,"r");
       $t="";
       while(!feof($fp)) {
          $t.=fread($fp,1024);
       }
       fclose($fp);
       print $t;
    ?>
    </textarea>
    <input type="hidden" name="file" value="<?=$file;?>">
    <?php
       }
       else
       {
    ?>
    Name of file: <input type="text" name="file"><br />
    <?php
        }
    ?>
    <br />
    <input type="submit">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any reflection/introspection/magic in PHP that will let you find the PHP file
Is there any javascript plugin/library/script that will can transform a standard PHP to use
Is there any existing code in Apache HttpClient or in the servlet API to
Are there any existing solutions for remote execution of commands on a windows server
Are there any good tools for visualising a pre-existing database schema? I'm using MySQL
Is there any free or commercial component written in .NET (no COM interop) that
Is there any way to capture the MouseDown even from the .NET 2.0 TextBox
First off, I'm not asking about how to generate documentation FROM PHP source. That's
Little question: With the following code... <?php $statement = SELECT * FROM TABLE; $query_unfetched
Is there any way to check whether a file is locked without using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.