Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- File Writing Issue
December 20, 2005, 1:59 pm
rate this thread
$file_contents = "<?php \n".
"$file_inc_news_id = '" .$id. "' \n" .
"include( $_SERVER['DOCUMENT_ROOT'] . '/news/news_item.php' );
$filename = $_SERVER['DOCUMENT_ROOT'] . "/" .date('his'). ".php";
$fp = fopen($filename , "w"); //to write a new file
fwrite($fp , $file_contents );
However I want to add the facility for the file to be written into a
sub directory that may or may not exist - if the folder exists then it
works fine - if it doesn't then it throws an error.
Without having to write a section of code to check if the folder
exists, is there a way of forcing PHP to build any required folders for