Hi All,

        Just need a bit of help on an issue i currently have. I have a php
script that is being called like a cgi and am trying to read stdin so that
i can get the raw http data that is being passed to apache. My problem is
that it all works fine outside the web environment but as soon as i call
the script over the net then it dosent work as expected.

        What it looks like its doing is that the script is being run by
apache just lke any other cgi script but because php knows that its
currently in a web environment it automaticly processes the data and
setups the global variables itsself, which i dont want it to do.

        Basicly i want to get it to run as if i had run it from the
command line.

        Below is the current code im using, as well as a very small shell
script that does what i want php to do just so that you can see what im
going on about.

PHP SCRIPT:

#!/usr/local/bin/php -q
<?php
set_time_limit(0);
ini_set('ignore_user_abort', '1');
$fp=fopen('php://stdin', 'r');
$data='DATA:';
while(!feof($fp)){
    $buffer=fread($fp, 1024);
    $data.=$buffer;
}
unset($buffer);
fclose($fp);
$fp=fopen('/tmp/phpupload', 'w+');
fwrite($fp, $data);
fclose($fp);
unset($fp);
print("Content-type: text/plain\n\ndone.");
print_r($GLOBALS);
?>

SHELL SCRIPT:

#!/bin/sh
while read stdin
do
        echo $stdin >> /tmp/upload
done
echo Content-type: text/plain
echo
echo done.

And i know that php does file uploads by its self, but i need to get the
data as it comes in and not save it to the filesystem.

Regards,
        William.

--
William Bailey.
http://wb.pro-net.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to