f



PHP 4.2.2 and php://stdin

Hello,
I am using php 4.2.2 in Red Hat 9.0 with apache 2.0.40 I try to build a
php script that accepts POST requests that contain multimedia data and
shoves them in a MySQL database. My problem is that it seems that I
cannot read the POST data from stdin.

I created the following php script to test it:

<?php

$in = fopen("php://stdin", "rb");
$line = fread($in, 10);
echo "Content-type: text/plain\n\n";
echo "len=".strlen($line)." OK\n";

?>

and however I try to POST a file either with cURL (curl --data-binary
@file http://....) or with netcat (nc host port, ...) what I get back is

len=0 OK

i.e. no data are read!

Any ideas?
Thanks!
0
ssfak (8)
9/8/2005 11:27:26 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

2 Replies
793 Views

Similar Articles

[PageSpeed] 13

Stelios G. Sfakianakis wrote:

> Hello,
> I am using php 4.2.2 in Red Hat 9.0 with apache 2.0.40 I try to build a
> php script that accepts POST requests that contain multimedia data and
> shoves them in a MySQL database. My problem is that it seems that I
> cannot read the POST data from stdin.
> 
> I created the following php script to test it:
> 
> <?php
> 
> $in = fopen("php://stdin", "rb");
> $line = fread($in, 10);
> echo "Content-type: text/plain\n\n";
> echo "len=".strlen($line)." OK\n";
> 
> ?>
> 
> and however I try to POST a file either with cURL (curl --data-binary
> @file http://....) or with netcat (nc host port, ...) what I get back is
> 
> len=0 OK
> 
> i.e. no data are read!
> 
> Any ideas?
> Thanks!

Hi,

$in = fopen("php://stdin", "rb");
????
I never saw such a way to receive a POST.
Where did you find it?

When somebody is submitting via a form some data, just receive it like this:
$_POST["name"];

When you need to receive a file, which is send through a construct like 
this:
<form enctype="multipart/form-data"  action="upload_process.php" 
method="post">
 <input type="file" name="uploadthingy">
 <input type="submit" value="upload">
</form>

You receive the file in the script upload_process.php in a different way.

Read on here: http://nl2.php.net/features.file-upload

It is all pretty straightforward. Pay attention to read/write permissions in 
the used directories.

In case I completely misunderstood your question, which can easily be the 
case since I never saw that fopen("php://stdin", "rb"); construct before, 
forgive me. :-)

Regards,
Erwin Moller
0
9/8/2005 1:26:41 PM
Erwin Moller wrote:
> Stelios G. Sfakianakis wrote:
> 
> 
>>Hello,
>>I am using php 4.2.2 in Red Hat 9.0 with apache 2.0.40 I try to build a
>>php script that accepts POST requests that contain multimedia data and
>>shoves them in a MySQL database. My problem is that it seems that I
>>cannot read the POST data from stdin.
>>
>>I created the following php script to test it:
>>
>><?php
>>
>>$in = fopen("php://stdin", "rb");
>>$line = fread($in, 10);
>>echo "Content-type: text/plain\n\n";
>>echo "len=".strlen($line)." OK\n";
>>
>>?>
>>
>>and however I try to POST a file either with cURL (curl --data-binary
>>@file http://....) or with netcat (nc host port, ...) what I get back is
>>
>>len=0 OK
>>
>>i.e. no data are read!
>>
>>Any ideas?
>>Thanks!
> 
> 
> Hi,
> 
> $in = fopen("php://stdin", "rb");
> ????
> I never saw such a way to receive a POST.
> Where did you find it?
> 
> When somebody is submitting via a form some data, just receive it like this:
> $_POST["name"];
> 
> When you need to receive a file, which is send through a construct like 
> this:
> <form enctype="multipart/form-data"  action="upload_process.php" 
> method="post">
>  <input type="file" name="uploadthingy">
>  <input type="submit" value="upload">
> </form>
> 
> You receive the file in the script upload_process.php in a different way.
> 
> Read on here: http://nl2.php.net/features.file-upload
> 
> It is all pretty straightforward. Pay attention to read/write permissions in 
> the used directories.
> 

I do not post through a form since the data are raw (e.g. an MPEG)
without being url encoded and so on. According to
http://www.php.net/wrappers.php :

<quote>
php://input allows you to read raw POST data. It is a less memory
intensive alternative to $HTTP_RAW_POST_DATA and does not need any
special php.ini directives. php://input is not available with
enctype="multipart/form-data".
</quote>

I am using the php://stdin because php://input is not available in php
4.2.2 but it seems that they are not equivalent.. On the other hand
$HTTP_RAW_POST_DATA requires AFAIK always_populate_post_data=On and it
seems to work with the "toy" script I gave but for some strange reason
it does not work with my full blown php script!!

I am really puzzled and frustrated!

Thank you anyway!

> In case I completely misunderstood your question, which can easily be the 
> case since I never saw that fopen("php://stdin", "rb"); construct before, 
> forgive me. :-)
> 
> Regards,
> Erwin Moller
0
ssfak (8)
9/8/2005 4:26:20 PM
Reply:

Similar Artilces:

Load average differences between Apache 1.3.37/PHP 4.4.6 and Apache 2.2.4/PHP 5.2.1
Hi folks, I've encountered something rather strange. This morning, I upgraded our production server, providing web services for our library website, from Apache 1.3.37/PHP 4.4.6 to Apache 2.2.4/PHP 5.2.1. The server, which normally exhibits a load average below 1 most of the time, spiked to loads that approached 100 if left alone. The interesting part of this is that this load average seems to be almost artificial - it appears to be caused by httpd processes stuck in a "closing connection" state (TIME_WAIT, in netstat). These processes are still running according t...

PHP pre 4.2 VS. PHP post 4.2
My local PHP install (for development/learning) is 4.3, but my hosting service uses 4.0.6. Without turning on registered globals, is there a common way these two versions can handle form data? 4.0.6 doesn't have import_request_variable(), $_POST, or $_REQUEST, and 4.3 chokes on $HTTP_POST_VARS[]. Thanks Chris 4.3 shouldn't choke on HTTP_POST_VARS - one thing you have to watch out for, however, is that HTTP_POST_VARS is not superglobal, so if you use it in a function, you still have to say global $HTTP_POST_VARS; etc... perhaps this is the reason it 'chokes'? Chris wrote: &g...

php-mcrypt module for php-4.2.2 ?
Hi I am looking for the above as my php version (Redhat) is that. Call me lazy, but I do not wish to compile php unless it becomes absolutely necessary, as it has been working fine so far. I have searched google for it, but to no avail so far. Does anyone know a source for it ? Upgrading to 4.2.3 is an option, but it will require upgrading large chunks of my installation that I do not have a problem with. Thanks, MS ...

CSWS 2 (apache) / PHP 1.2 (php 4.2.3) / Oracle 9i OCI8 connectivity under OpenVMS
I'm currently trying to interface CSWS 2.0 (apache) / PHP v1.2 (PHP 4.3.2) with an Oracle 9.2 database under OpenVMS 7.3.2 The database connection works fine, but i've a problem with OCIexecute when i'm trying to select varchar value. My script works fine with int value, but give no resultt (error page) when there's a varchar colum in the select statement Someone Have exeprienced such problem ? Who can help me with APACHE/PHP/Oracle9I/OpenVMS configuration ? Environnement problem ? NLS problem ? Thanks in advance for all Best regards ...

php degugger on php 5.2.2 (xampp 1.6.2) real brainer
Hi, I tried to get php dbg debugger working on my machine but it doesn't work at all. Ok, what i did: copied php_dbg-5.2.x.dll (for PHP 5.2.x version) into my xampp/php/ext directory next, modified /xampp/apache/bin/php.ini file appending: [debugger] extension=php_dbg-5.2.x.dll debugger.enabled=on debugger.profiler_enabled=on debugger.hosts_allow=localhost 127.0.0.1 ;debugger.hosts_deny=ALL debugger.ports=7869, 10000/16 debugger.JIT_host = clienthost debugger.JIT_port = 7869 Now, when i restard my server and try to get http://localhost my apache crashes and windows gives me a wind...

Suse 8.2 pro Apache 2.0.44 + PHP 4.3.1-24 = PHP not working
Hi Group! I am using Suse Linux 8.2 and the Apache and PHP versions shipped on CD. It seems, that the apache server still doesn't know how to treat php files. The httpd.conf looks like this: ----- LoadModule php4_module /usr/lib/apache2-prefork/libphp4.so AddModule mod_php4.c # # PHP 4.x: # <IfModule mod_php4.c> AddType application/x-httpd-php .php .php3 .php4 .phtml AddType application/x-httpd-php-source .phps </IfModule> ----- But anyway, if i try to open a php file like http://192.168.1.101/test.php, I receive a download dialog (Save as...). If i...

Apache 2.2.4 ignores PHP 5.2.4 scripts on Win2K3
Hi all PHP newbie here, 1) I disabled IIS. 2) Loaded Apache 2.2.4 on Win2K3. 3) Loaded PHP 5.2.4 pretty much bare bones, but included MySQL, SMTP, SOAP and ZIP extensions. Installers: apache_2.2.4-win32-x86-openssl-0.9.8d.msi php-5.2.4-win32-installer.msi Installer changed the httpd.conf file and added the following: PHPIniDir "C:/Program Files/PHP/" LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll" AddType application/x-httpd-php .php Error log shows that PHP was configured: .... [Fri Sep 14 16:07:49 2007] [notice] Apache/2.2.4 (Win32) PHP/5.2.4 configu...

Why The Script Ran on PHP 4.2.3, but not 4.2.4
What is the big change from 4.2.4 from 4.2.3? I have many scripts not runing now. The scripts are working fine in PHP 3.x While, it should be 4.2.3 and 4.3.4 Why scripts running fine in 4.2.3 do not run in 4.3.4? > What is the big change from 4.2.4 from 4.2.3? I have many scripts not runing > now. The scripts are working fine in PHP 3.x > > On Sat, 10 Apr 2004 03:28:38 +0000, Finding Best Hosting wrote: > What is the big change from 4.2.4 from 4.2.3? I have many scripts not > runing now. The scripts are working fine in PHP 3.x 4.2.3 - Working ??? 4.2.4 - Not working...

Apache 2.2.2 and PHP 5.1.4 on Win2k crashing
I just installed Apache 2.2.2 on my Windows 2000 (SP4) machine to test the new version. Everything works except PHP (version 5.1.4): when starting Apache, it pops out a message saying that it is unable to locate the module (even set on the correct path!), stops the execution and exits. On the other side, PHP works fine with Apache 2.0.55, so It's not a problem of a broken build. Got ideas? Thanks. -- Massimo Lombardo unwiredbrain@gmail.com wrote: > I just installed Apache 2.2.2 on my Windows 2000 (SP4) machine to test > the new version. > Everything works except PHP (version ...

Upgrade from PHP Version 4.2.2 to 4.3.10
hi, I am currently running PHP Version 4.2.2 on Red Hat Linux release 9 (Shrike) with Apache/2.0.40 (Red Hat Linux) I would like to upgrade to the latest version of PHP (4.3.10 ?). PHP was pre-installed as RPM version, I would like to know where i can find an RPM upgrade... What are the steps to take, will original php.ini be overwritten, do i need to change Apache confg files. thanks. *** seajay wrote/escribió (17 Jan 2005 09:40:13 -0800): > I am currently running > PHP Version 4.2.2 on Red Hat Linux release 9 (Shrike) > with Apache/2.0.40 (Red Hat Linux) > I would like...

Problems compiling Sablotron into PHP 4.3.2 on RedHat 7.2 #2
Hi, I'm trying to install Sablotron on Red Hat Linux release 7.2 (Enigma). I've got Sablotron to compile. I now get the following error when running ./configure on PHP: checking for Sablotron libraries in the default path... found in /usr/local checking for sablot-config... found checking for Sablotron version... configure: error: Sablotron version 0.96 or greater required. [root@redhat1 php-4.3.2]# In config.log: configure:75340: checking for sablot-config configure:75358: checking for Sablotron version configure:75383: gcc -o conftest -g -O2 -I/usr/local/include -Wl,-rpath,/u...

Is Php built in function ' imagecreate()' compatible in Php version 5.2.2 ?
Hi All, I have the php version 5.2.2 . When I am using " $im = imagecreate(......); " I am getting the following message "Fatal error: Call to undefined function imagecreate() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\server.php on line 32" I want to know whether "imagecreate()" is compatible in PHP version 5.2.2.? saikiran.iitkgp@gmail.com wrote: > Hi All, > > I have the php version 5.2.2 . When I am using > > > " $im = imagecreate(......); " I am getting the following message > > > &q...

<?= does not work on Windows XP Apache 2.2.x and PHP 5.2.4
When i do <?php echo "This works fine"; ?> Everything works fine. But when i do <?= "Some text"?> nothing works. Any ideas? Best Regards, Nicos On Fri, 28 Sep 2007 10:06:26 +0200, Nicos <nicoskk@gmail.com> wrote: > When i do > <?php > echo "This works fine"; > ?> > Everything works fine. But when i do > <?=3D "Some text"?> nothing works. Any ideas? It relies on short_open_tags, which have been disabled by default for a = = very long time now. Don't rely on them, only keep the setting on fo...

PHPBB2, PHP 4.3.4, MySQL 4.1.1, Apache 2.0.49, Fedora 2
My combination is: PHPBB2, PHP 4.3.4, MySQL 4.1.1, Apache 2.0.49, Fedora 2 Anyone out there has a successful combination of newer versions ? fr gr Erik ...

Apache 2.2.3 PHP 4.4.5 Install Fails
Sigh. I have Apache 2.2.3 installed and running on WinXP Pro SP2. I installed PHP 4.4.5 and added the following lines in httpd.conf PHPIniDir C:/PHP445/ LoadModule php4_module C:/PHP445/php4apache2.dll When I restarted Apache, i got this error: The Apache service reported the following error: >>> httpd.exe: Syntax error on line 488 of C:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf: Cannot load C:/PHP445/php4apache2.dll into server: The specified module could not be found. Turns out that php4apache2.dll requires libapr.dll, libaprutil.dll and libapriconv.dll...

PHP with Indian PHP Developers #2
Dear all, If you want to make a PHP web application, or need to Hire PHP Developer contact a leading PHP Web Development Compnay http://www.virtueinfo.com/ php-developers/php-web-development.htm ...

Does 4/2/2= (4/2)/2 =1 OR = 4/(2/2)=4
I don't have matlab and I am trying to translate some simple matlab code. Does 4/2/2 = (4/2)/2 = 1 or 4/2/2 = 4/(2/2) = 4 On 9/11/2012 9:43 AM, sarah.englander@gmail.com wrote: > I don't have matlab and I am trying to translate some simple matlab code. > > Does 4/2/2 = (4/2)/2 = 1 yes. At a given precedence level (and obviously two of the same operators are the same level) evaluation proceeds from LtoR. ....snip... <http://www.mathworks.com/help/techdoc/matlab_prog/f0-40063.html#f0-38155> -- dpb <none@non.net> wrote in message <...

Trying to build PHP 4.3.0 with Apache 2.2.2 on SUSE 9.1
What a mix! Whilst I grep around for the first set of problems, I thought I'd ask any generous members of this PHP community for clues... I've started by trying out the instructions at: http://dan.drydog.com/apache2php.html Got this out of the make: ----------------------------------------------------------------------------------------------- /bin/sh libtool --silent --mode=compile gcc -Isapi/apache2filter/ -I/root/downloads/php-4.3.0/sapi/apache2filter/ -DPHP_ATOM_INC -I/root/downloads/php-4.3.0/include -I/root/downloads/php-4.3.0/main -I/root/downloads/php-4.3.0 -I/usr/local/Apa...

imagerotate problem with PHP 4.3.9
Recap: Using imagerotate within PHP 4.3.9 - PHP 5.2.0 for both XP and Linux, all using GD2 If you rotate an image 180 degrees, all is fine If you rotate an image > 0 degrees and < 180 degrees, or > 180 degrees and < 360 degrees, while the image will rotate, its dimensions are somehow not refactored and as a result you get a rather annoying black bar in the newly-rotated image, along with part of your image being cropped off. I learned about a possible workaround with ImageMagick's convert command, but has anyone found a better solution (other than using XP's built-in im...

Help Needed: Upgrade Fedora 4 / Apache 2 to PHP 5.2.x from 5.0.4
Help Needed: Upgrade Fedora 4 / Apache 2 to PHP 5.2.x from 5.0.4 I've been testing Joomla as a content manager for the County offices, and it looks pretty good. Unfortunately, I decided to upgrade it from the 1.0.13 version to 1.5 as we get ready to go live with the web site... and the update installation gives an error in XML processing, which seems (from what I've been able to dredge up in forum discussions) to stem from a known bug in PHP 5.0.4... I've seen this same error from a couple of other programs that want to upload XML data to PHP based server software, too, so I'...

rebuild php-4.2.2-17.2 with "--with-xml --enable-xslt --with xslt-sablot" on RedHat 9.0
Hi, I have RedHat 9.0 and installed by default Apache+PHP. By default XSLT Sablotron support is not enabled, so how can I rebuild PHP with xslt support? I know that I can rebuild it from sources as described on http://www.protonicdesign.com/tutorial/sablot_and_php.php, but I want to do it without uninstalling and breaking present configuration. I just need append support for XSLT Sablotron. Sincerely, Rustam Bogubaev Hi Rustam! On 14 Sep 2003 14:23:19 -0700, rbogubaev@bookinturkey.com (Rustam Bogubaev) wrote: >Hi, > >I have RedHat 9.0 and installed by default Apache+PHP. By defa...

updating PHP 4.2.2 on Red Hat 9
A few months ago I installed Red Hat 9. I specified Apache, PHP and MySQL in the intallation process. With phpinfo() it was confirmed that PHP Version 4.2.2 is installed on this PC. With Red Hat 9 doing the periodic up2dates, I am wondering - will PHP be updated to 4.3.x via up2date or not? If yes, any idea when this might happen? If no, can you tell me where I can find directions on how to manually update to PHP 4.3.x ? Thanks. lothario@email.com (luther) wrote in message > A few months ago I installed Red Hat 9. > I specified Apache, PHP and MySQL in the intallati...

Lithuanian language! Apache 2 + php 4.3.2
my clients on my server complain that they can't see lithuanian language, what i saw is when i go to: http://www.mntkz.net/~device/lt.html then there is some messed up letter showing, but changing view->encoding to Baltic(Windows) it shows good. what should i tell them? or there is something i could do? i installed apache2 like week ago, and now there is a problem, before that i didn't have any problems... whats wrong? what should i add to config? or what should i install? thanks Mantuks@centras.lt (Mantas) wrote: > my clients on my server complain that they can...

Apache 2.2 and PHP
I have upgraded to Apache 2.2 and php5.0.4 (both from SUNFREEWARE) and am now getting errors: httpd: Syntax error on line 110 of /usr/local/apache2/conf/httpd.conf: API module structure `php5_module' in file /usr/local/apache2/modules/libphp5.so is garbled - perhaps this is not an Apache module DSO? This has been reported at various places but there has been NO answer... Any EXPERT know how to resolve? Yes,the libphp5.so exists with the same rights as all the others in the MODULES directory. Thanks Carl On Mon, 13 Feb 2006, Carl Hilton wrote: > I have upgraded to Apache 2.2 and ...

Web resources about - PHP 4.2.2 and php://stdin - comp.lang.php

Remove automatic stdin detection · Issue #72 · feross/standard · GitHub
... work somehow, so thought we could make it work too, but @substack says it's not. Let's just make the user explicitly pass - if they want stdin ...

Programming Challenges - Quora
feature for our iPhone app. Each question on Quora can have one or more topics associated with it. This feature allows us to display topics and ...

Command-line interface - Wikipedia, the free encyclopedia
A command-line interface (CLI) is a means of interaction between a human user and a computer program , or between two programs, where the user ...

oggfwd
ogg fwd ffmpeg2theora Streaming HowTo pipes an ogg stream to an icecast server. just reads from stdin and sends to icecast server using libshout ...

VLC 2.0.2 update includes Retina Display support
... initialization Volume level is no longer applied to the file output Fixed sampling rate for the JACK output Lua Scripts Fixes for stdin/stdout ...

SEEing LaTeX 15: Comments on Comments
I really thought that getting comments working in the SubEthaEdit LaTeX mode would be easy. It wasn't. My expectation was that I could just adapt ...

Commands tagged col - commandlinefu.com
Great UNIX/Bash commands tagged with col - see these and many other invaluable command-line nuggets at commandlinefu.com

VLC Media Player For Mac Updated With Retina Graphics And Many More Improvements
... initialization Volume level is no longer applied to the file output Fixed sampling rate for the JACK output Lua Scripts Fixes for stdin/stdout ...

GuizmOVPN - FAQ
GuizmOVPN - An OpenVPN GUI for iPhone/iPod/iPad

Ideone.com - Online IDE & Debugging Tool > > C/C++, Java, PHP, Python, Perl and 40+ compilers and intepreters ...
with Ada. Integer_Text_Io , Ada. Text_Io ; use Ada. Integer_Text_Io , Ada. Text_Io ; procedure Test is subtype Small is Integer range 0 .. 99 ...

Resources last updated: 3/1/2016 4:58:41 AM