> # This is the standard input script.
>
> $fp = fopen("php://stdin","r");
> $writer_file = fopen("test.txt","w");
> fwrite($writer_file,"$fp");
> fclose($writer_file);
> fclose($fp);
>
> ?>
>
> As stated, it does create the test.txt in the specified location,
> however,
> upon inspection of the file, it only shows the following text:
> "Resource id
> #1" on the first line, and that's it.

This is what would be expected, your writing a file pointer to file not the
coentents of the stdin, you need to do somthing along the lines of the
following

// Untested Code

/* -*- Open stdin for reading -*- */
$fp = fopen("php://stdin","r");

/* -*- Open test.txt for writing -*- */
$writer_file = fopen("test.txt","w");

/* -*- Check both were opened -*- */
if($fp && $writer_file) {

    /* -*- Read in stdin -*- */
    while(!feof($fp)) {
        $stdin .= fread($fp, 4096);
    }

    /* -*- Write to test.txt -*- */
    if (sizeof($stdin) != fwrite($writer_file, $stdin, sizeof($stdin))) {
        //Not all of stdin was written to file
    }
    else {
        /* -*- Close Files -*- */
        fclose($writer_file);
        fclose($fp);
    }
}
else {
        //files were not opened
}

James


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to