Jump to content

Problem with filesystems!


Brajan

Recommended Posts

[code=php:0]
<?php
   $files = array("/Ny_mapp/start.php/","lagg_till_nyheter.php");
   $result = count($files);
   $fileid = $_GET['fileid']; 


   if(isset($_POST['submit']))
   {
      if(!file_exists($files))
      {
         echo "File not exist";
      }
      elseif(!is_writeable($files))
      {
         echo "U cannot write to the file";
      }
      else
      {
     
            if(!$fp = fopen($files, 'w'))
            {
               echo "Open file: Negatuve ";
            }
         
         elseif(fwrite($fp, stripslashes($_POST['content'])) == false)
         {
            echo "Write to the file: Negative";
         }
            
      }
   }

   //Lista filer som finns i array $files
   for($i = 0; $i < count($files); $i++)
   {
      echo sprintf('<a href="%s?page=meny.php&fileid=%d">Ändra %s</a>',$_SERVER['PHP_SELF'],$i,$files[$i]); 
      echo "<br>";
               
   }
   echo "Du har valt " . $files[$fileid] . "";
   
?>   

<form method="post">
Lägg till hidden i formen.
<form method="post">
    <input type="hidden" name="fileid" value="<?php echo $fileid; ?>" />

<textarea name="content" rows="20" cols="50"><?php
                       
      echo (file_exists($files[$fileid])) ? htmlentities(file_get_contents($files[$fileid])) : "";
                 
                  ?>
                  </textarea>
<input type="submit" name="submit_save" value="save"><br>
</form> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.