ninevolt1 Posted August 18, 2009 Share Posted August 18, 2009 I have a script which makes a file: add article("article_$article_id.php"); How do I modify this so that I can save it up one directory? I've tried putting ../ in several places but it doesn't seem to be the trick. Link to comment https://forums.phpfreaks.com/topic/170910-how-do-i-save-a-file-up-one-directory/ Share on other sites More sharing options...
awpti Posted August 18, 2009 Share Posted August 18, 2009 We would need to see the source for said function. You would generally have to add it to the fopen() call. Link to comment https://forums.phpfreaks.com/topic/170910-how-do-i-save-a-file-up-one-directory/#findComment-901423 Share on other sites More sharing options...
ninevolt1 Posted August 18, 2009 Author Share Posted August 18, 2009 Thanks for the reply. Here is the add article code: function add_article($filename, $news) { if(file_exists($filename)){ $fh = fopen($filename, "r"); $old_news = fread($fh, filesize($filename)); fclose($fh); } /* TODO: Multipage articles preg_match_all("<!--ARTICLE PAGE=(\d*)-->", $old_news, $matches; if( count($matches[0]) >= $max_summary){ $oldfilename = $filename.($matches[0][0]+1); } */ $fh = fopen($filename, "w"); $news = stripslashes($news); fwrite($fh, "$news $old_news"); fclose($fh); } Link to comment https://forums.phpfreaks.com/topic/170910-how-do-i-save-a-file-up-one-directory/#findComment-901424 Share on other sites More sharing options...
ninevolt1 Posted August 18, 2009 Author Share Posted August 18, 2009 Never mind. It is magically working. Case closed. Thanks! Link to comment https://forums.phpfreaks.com/topic/170910-how-do-i-save-a-file-up-one-directory/#findComment-901426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.