Reply to File Writing Issue

Your name:

Reply:


Posted by thehuby on 12/20/05 15:59

I am writing a file using PHP and all is great thus far:

$file_contents = "<?php \n".
"\$file_inc_news_id = '" .$id. "' \n" .
"include( \$_SERVER['DOCUMENT_ROOT'] . '/news/news_item.php' );
\n" .
"?>";
$filename = $_SERVER['DOCUMENT_ROOT'] . "/" .date('his'). ".php";
$fp = fopen($filename , "w"); //to write a new file
fwrite($fp , $file_contents );
fclose($fp);

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
me?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация