NYCPHP Meetup

NYPHP.org

[nycphp-talk] phantom file writing errors

inforequest sm11szw02 at sneakemail.com
Tue Jul 27 03:52:50 EDT 2004


Couldn't repeat the error here.

Assuming $all_films[$x]["film_id"]="film_" . $x . "_id";
as long as   $_SERVER['DOCUMENT_ROOT']  . '/_admin/distributors/output/' 
existed, this worked fine.




Marc Antony Vose suzerain-at-suzerain.com |nyphp 04/2004| wrote:

>
> // step through the films array and output the file
> for( $x=0; $x<count($all_films); $x++ ){
>
>
> //....snip snip: a few setup variables
>
> // MAIN_ROOT, in this case = $_SERVER['DOCUMENT_ROOT']
>
> // the directory name is the film_id
> $output_dir = MAIN_ROOT . '/_admin/distributors/output/' . 
> $all_films[$x]["film_id"];
> // the file name
> $output_file = 'distributors.html';
> // build the path, for convenience
> $output_path = $output_dir . "/" . $output_file;
>
> // create the directory, if necessary
> if( !file_exists($output_dir) && !is_dir($output_dir) ){
>     mkdir($output_dir,0755);
> }
>
> //...snip snip: the code that populates the variable $output
>
> // output the file
> $output_h = fopen($output_path,"w");
> fwrite($output_h,$output);
> fclose($output_h);
>
>
> //...snip snip: code that copies the file to a remote server
>
>
> }








More information about the talk mailing list