php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #36905 PUT returns no data via php://stdin
Submitted: 2006-03-29 07:59 UTC Modified: 2006-03-30 03:57 UTC
From: dbarrett at quinthar dot com Assigned: simp (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.4.2 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dbarrett at quinthar dot com
New email:
PHP Version: OS:

 

 [2006-03-29 07:59 UTC] dbarrett at quinthar dot com
Description:
------------
Reading from 'php://stdin' should produce the contents of the file uploaded via PUT, but nothing actually comes out.  This is the same issue as described in bug #10383 (and marked as bogus), though it is anything but.


Reproduce code:
---------------
<?php
        $filename = "myputfile.ext";
        $totalWritten = 0;
        $inFP  = fopen( "php://stdin", "rb" );
        $outFP = fopen( $filename, "wb" );
        fwrite( $outFP, "testing 1, 2, 3" );
        while( $data = fread( $inFP, 1024 ) )
        {
                fwrite( $outFP, $data );
                $totalWritten += strlen( $data );
        }
        fclose($inFP);
        fclose($outFP);

        if( $totalWritten ) header( "HTTP/1.0 200 Success ($filename)" );
        else                header( "HTTP/1.0 404 Failed ($filename)" );
?>


Expected result:
----------------
I expected the test file to successfully upload, and the script to return 200 Success.


Actual result:
--------------
In actuality, the file does not upload.  Rather, though it's able to open and write the test string to the file, it does not write any of the file contents itself.  The actual command output follows:

-------------- Client Side ------------------
D:\>type test
Hello world!
D:\>curl -i -T test http://www.XXXX.com/
HTTP/1.1 100 Continue

HTTP/1.1 404 Failed (myputfile.ext)
Date: Wed, 29 Mar 2006 07:17:03 GMT
Server: Apache
X-Powered-By: PHP/5.0.5
Content-Length: 1
Content-Type: text/html

-------------- Server Side ------------------
[root@www www.XXXX.com]# cat myputfile.ext
testing 1, 2, 3[root@www www.XXXX.com]#


I've confirmed this identical behavior using both 'curl' and 'libcurl', on two different versions of Linux/Apache/PHP.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-29 14:54 UTC] bjori@php.net
STDIN/php://stdin is only set in php-cli, use php://input
..and read the warnings on http://php.net/manual/en/function.fread.php
 [2006-03-29 14:54 UTC] bjori@php.net
.
 [2006-03-29 21:17 UTC] dbarrett at quinthar dot com
Switching from "php://stdin" to "php://input" worked great, thanks!  Should the documentation be updated to reflect this?  The 'Put Method Support' documentation seems simply incorrect in light of this:

http://us3.php.net/manual/en/features.file-upload.put-method.php
 [2006-03-29 22:49 UTC] bjori@php.net
Re-opend as documentation problem.
That page needs makeover.
 [2006-03-30 03:57 UTC] simp@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 04:00:01 2025 UTC