php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32812 Post Multipart/formdata, $HTTP_POST_VARS doesn't get initialized correctly!
Submitted: 2005-04-24 21:29 UTC Modified: 2005-04-24 22:40 UTC
From: samuel at replicon dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.4 OS: Windows 2000
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: samuel at replicon dot com
New email:
PHP Version: OS:

 

 [2005-04-24 21:29 UTC] samuel at replicon dot com
Description:
------------
when post multipart/form-data, $HTTP_POST_VARS doesn't get initialized correctly, actually, it's empty.

Expected result:
----------------
$HTTP_POST_VARS should contain post data


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-24 21:55 UTC] samuel at replicon dot com
Code to reproduce the bug
=========================

<?php
//if ($HTTP_POST_VARS['submit']) {	// this statement doesn't work since $HTTP_POST_VARS is always empty!!
if (isset($_POST['submit'])) {

  // for debugging purpose
  print_r($_POST);
  print_r($HTTP_POST_VARS);
  print_r($HTTP_POST_FILES);

  if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {
    $error = "You did not upload a file!";
    unlink($HTTP_POST_FILES['file']['tmp_name']);
  } else {
    copy($HTTP_POST_FILES['file']['tmp_name'],"/finallocation/".$HTTP_POST_FILES['file']['name']);
    unlink($HTTP_POST_FILES['file']['tmp_name']);
    print "File has been successfully uploaded!";
    exit;
  }
}
?>

<html>
<head></head>
<body>
<form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
<?=$error?>
<br><br>
Choose a file to upload:<br>
<input type="file" name="file"><br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
 [2005-04-24 21:58 UTC] samuel at replicon dot com
refine summary.
 [2005-04-24 22:07 UTC] tony2001@php.net
Use var_dump($HTTP_POST_VARS); to see the contents of the variable.
Also check $_POST too.
 [2005-04-24 22:13 UTC] samuel at replicon dot com
var_dump($HTTP_POST_VARS) --> NULL
  var_dump($HTTP_POST_FILES) --> NULL
 [2005-04-24 22:16 UTC] samuel at replicon dot com
var_dump($_POST) --> array(1) { ["submit"]=> string(6) "submit" }
 [2005-04-24 22:20 UTC] tony2001@php.net
Check that register_long_arrays is On.
 [2005-04-24 22:31 UTC] samuel at replicon dot com
Thanks, the Check that register_long_arrays is off. After turned it on, everything is working now.
 [2005-04-24 22:40 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 14:01:28 2024 UTC