Reply to Re: PHP 4.2.2 and php://stdin

Your name:

Reply:


Posted by Stelios G. Sfakianakis on 09/08/05 19:26

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

[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

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