php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4763 PHP_PUT_FILENAME is gone?
Submitted: 2000-06-01 20:45 UTC Modified: 2000-08-18 21:54 UTC
From: lrlait at code916 dot gsfc dot nasa dot gov Assigned:
Status: Closed Package: Other
PHP Version: 4.0 Release Candidate 2 OS: IRIX
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: lrlait at code916 dot gsfc dot nasa dot gov
New email:
PHP Version: OS:

 

 [2000-06-01 20:45 UTC] lrlait at code916 dot gsfc dot nasa dot gov
The technique described in the PHP manual to handle
file upload requests using the HTTP PUT method does not
seem to work, possibly because the $PHP_PUT_FILENAME 
variable mentioned there seems to have disappeared in PHP 4.

According to Chapter 18 in the PHP manual, PHP handles
PUT requests in a way similar to how it handles POST
requests, by stashing the uploaded file into a temporary
file.  OK, I've done POST stuff in PHP before; I need
the name of the temporary file.  And the manual says that 
I can get the name of the temporary file in 
$PHP_PUT_FILENAME.

But: (a) I find that $PHP_PUT_FILENAME never seems to 
         be set to anything
     (b) grepping the PHP 4.0.0 source code for
         'PHP_PUT_FILENAME' turns up no matches
     (c) grepping the PHP 3.0.15 source code for
         'PHP_PUT_FILENAME' turns up a match in 
         functions/post.c

I do see a mention of something called $HTTP_POST_FILES
in the 4.0.0 NEWS file and the source code, but I see no documentation on how to use it, or if it can be used
for PUT method stuff.

And there is nothing in the TODO file about this either.

Documentation problem?  Not-yet-reimplemented feature?

I am running PHP 4.0.0 as a module under Apache 1.3.12,
and I do have a "Script PUT" line in my apache config file.

-----------  put.php (dumps to log file) ------------
<script language="php"> 

  if(!isset($PHP_AUTH_USER)) {
    Header("WWW-Authenticate: Basic realm=\"Download test\"");
    Header("HTTP/1.0 401 Unauthorized");
    echo "Cancelled\n";
    exit;
  } else {
    echo "Hello $PHP_AUTH_USER.<P>";
    echo "You entered $PHP_AUTH_PW as your password.<P>";
  }

$logfile="puttest/log.txt";

$ff = fopen($logfile,"a");
if ( $ff ) {

   fwrite($ff,"========= " . date("Y-m-d\TH:i:s") . "=======\n");

   fwrite($ff,"REQUEST_METHOD=" . getenv("REQUEST_METHOD") . "\n");
   fwrite($ff,"REQUEST_URI=" . getenv("REQUEST_URI") . "\n");
   fwrite($ff,"PHP_PUT_FILENAME=" . $PHP_PUT_FILENAME . "\n");

   fwrite($ff,"Apache headers=\n");
   $apchead = getallheaders();
   $apcnames = array_keys($apchead);
   foreach ($apcnames as $apcvar) {
      fwrite($ff,"   " . $apcvar . " = " . $apchead[$apcvar] . "\n");
   }

   fwrite($ff,"HTTP_POST_FILES=\n");
   if ( isset($HTTP_POST_FILES) ) {
      $postnames = array_keys($HTTP_POST_FILES);
      foreach ($postnames as $postvar) {
         fwrite($ff,"   " . $postvar . " = " . $HTTP_POST_FILES[$postvar] . "\n");
      }
   }   

   fwrite($ff,"Env vars=\n");
   $envnames = array_keys($HTTP_ENV_VARS);
   foreach ($envnames as $envvar) {
      fwrite($ff,"   " . $envvar . " = " . $HTTP_ENV_VARS[$envvar] . "\n");
   }

   fwrite($ff,"Server vars=\n");
   $srvnames = array_keys($HTTP_SERVER_VARS);
   foreach ($srvnames as $srvvar) {
      fwrite($ff,"   " . $srvvar . " = " . $HTTP_SERVER_VARS[$srvvar] . "\n");
   }

   if ( isset($HTTP_GET_VARS) ) {
      fwrite($ff,"Get vars=\n");
      $getnames = array_keys($HTTP_GET_VARS);
      foreach ($getnames as $getvar) {
         fwrite($ff,"   " . $getvar . " = " . $HTTP_GET_VARS[$getvar] . "\n");
      }
   }   

   if ( isset($HTTP_POST_VARS) ) {
      fwrite($ff,"Post vars=\n");
      $getnames = array_keys($HTTP_POST_VARS);
      foreach ($getnames as $getvar) {
         fwrite($ff,"   " . $getvar . " = " . $HTTP_POST_VARS[$getvar] . "\n");
      }
   }
   fwrite($ff,"......... " . date("Y-m-d\TH:i:s") . ".......\n");
   fclose($ff);
   echo "OK, done\n";
} else {
   echo "No log file!\n";
}

</script>
-------------- log.txt (output from put.php )--------------
========= 2000-06-01T13:07:13=======
REQUEST_METHOD=PUT
REQUEST_URI=(expunged)/WRITETEST
PHP_PUT_FILENAME=
Apache headers=
   Accept = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
   Accept-Charset = iso-8859-1,*,utf-8
   Accept-Encoding = gzip
   Accept-Language = en
   Connection = Keep-Alive
   Content-Length = 1
   Host = aeolus.gsfc.nasa.gov:183
   Pragma = no-cache
   User-Agent = Mozilla/4.7 [en]
HTTP_POST_FILES=
Env vars=
   (expunged)
Server vars=
   PATH_TRANSLATED = (expunged)/put.php
   PHP_SELF = (expunged)/WRITETEST
   argv = Array
   argc = 0
   PHP_AUTH_USER = (expunged)
   PHP_AUTH_PW = (expunged)
Get vars=
......... 2000-06-01T13:07:13.......


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-26 05:58 UTC] zak@php.net
Could you provide output from calling phpinfo after attempting a PUT to your script?
 [2000-07-27 17:57 UTC] zak@php.net
User provided additional information - need to talk to developers...
 [2000-07-27 20:07 UTC] zak@php.net
The cURL functions should let you use PUT. AFAIK there are no docs for the cURL functions yet.  You will have to grep the source code for cURL. You can get more information on the cURL library at http://curl.haxx.se/

(Thanks to Sterling Hughes for the cURL info)
 [2000-08-18 21:54 UTC] sniper@php.net
No feedback from user.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC