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

Your name:

Reply:


Posted by Erwin Moller on 09/08/05 16:26

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

[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

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