Brajan Posted February 18, 2009 Share Posted February 18, 2009 Hi! I'm trying to learn how to work with files with PHP, but the thing I work on doesn't work... The purpose of my application is that the administrator shall be able to edit the content of different links. For example, the code for the link home.php shall be included in a textarea, then, the administrator can edit the code. The problem is that the files, which is under the administrator directory, isn't included in the textarea. Why? Can someone help me? <?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 "The file dosen't exist"; } elseif(!is_writeable($files)) { echo "Write file failed"; } else { if(!$fp = fopen($files, 'w')) { echo "Open file failed"; } elseif(fwrite($fp, stripslashes($_POST['content'])) == false) { echo "Write to the file failed."; } } } //Lista filer som finns i array $files for($i = 0; $i < count($files); $i++) { echo sprintf('<a href="%s?page=meny.php&fileid=%d">Change %s</a>',$_SERVER['PHP_SELF'],$i,$files[$i]); echo "<br>"; } echo "U have chooses " . $files[$fileid] . ""; ?> <form method="post"> Lag 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="spara"><br> </form> Quote Link to comment https://forums.phpfreaks.com/topic/145773-problem-with-filesystem/ Share on other sites More sharing options...
premiso Posted February 18, 2009 Share Posted February 18, 2009 Have you tried using the full absolute path to the files? Quote Link to comment https://forums.phpfreaks.com/topic/145773-problem-with-filesystem/#findComment-765350 Share on other sites More sharing options...
Brajan Posted February 18, 2009 Author Share Posted February 18, 2009 Yes, when I change to /var/www/Ny_mapp/start.php i doesen't either. EDIT: Now it works . Before I tried, but it not worked. Well well. Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/145773-problem-with-filesystem/#findComment-765351 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.