Bug #26004 [Com]: $_POST variables not set when using enctype="multipart/form-data"

From: Date: Tue, 30 Jul 2019 16:25:58 +0000
Subject: Bug #26004 [Com]: $_POST variables not set when using enctype="multipart/form-data"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222018@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=26004&edit=1

 ID:                 26004
 Comment by:         luckyranger at gmail dot com
 Reported by:        jacknorton101 at hotmail dot com
 Summary:            $_POST variables not set when using
                     enctype="multipart/form-data"
 Status:             No Feedback
 Type:               Bug
 Package:            *General Issues
 Operating System:   RedHat Linux 9
 PHP Version:        4.3.3
 Block user comment: N
 Private report:     N

 New Comment:

WEll it is not a bug and I figured out that I had not set the "name" attributes for the
input elements that I was trying to access.

also $_REQUEST['element-name'] works better.


Previous Comments:
------------------------------------------------------------------------
[2011-10-11 12:33:17] seyhun_cavus at hotmail dot com

Here is the fix: Check the message of gimi.
[2010-02-03 16:17 UTC] gimi dot alb at gmail dot com,

Also you should check (into begin of your script)
"post_max_size, upload_max_filesize, memory_limit"
values to work correctly and safely!

For Example:
http://www.php.net/manual/en/features.file-upload.php#73762

YOU SHOULD CHECK:
================================== 
ini_get('post_max_size');
ini_get('upload_max_filesize');
ini_get('memory_limit');
================================== 

Regards.
 Seyhun Cavus.

------------------------------------------------------------------------
[2011-03-28 02:15:52] mzbirka at centrum dot cz

Just for the record, in my case similar behavior was observed and the cause was 
restrictions in the suhosin - hardened debian distribution, 
suhosin.post.max_name_length specifically.

------------------------------------------------------------------------
[2010-02-13 12:57:31] sudeshkmr at yahoo dot com

I faced the same problem and nothing worked. I have tested on Apache 2.2, PHP 5.3 on Windows Vista.
I also tested on Ubuntu (Karmic) with Apache 2.2 and PHP 5.3. I also tested with nGinX 0.8 and PHP
5.3.

Then I found a workaround. The action="" parameter should not be the script page itself on
which you have file upload form. For example, you have a page index.php with the upload form.

<form action="upload.php" enctype="multipart/form-data"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="200000"> 
<input type="file" size="40" name="upload">
<input type="submit" value="Upload">
</form>

The action="upload.php" <-------- This page has to be different than the file upload
form page, and it works on all configurations of PHP!

Do not use <php?=$_SERVER['PHP_SELF']?> for the action parameter.

------------------------------------------------------------------------
[2010-02-03 16:17:33] gimi dot alb at gmail dot com,

Some Apache hosts have problem parsing variables from .htaccess files.
They do not throw any error, but they just unset the variables. 
I had the problem with the POST variable not being set, when I migrated to a new host. After hours
of debugging, I found out that 
these variables:
 #php_value upload_max_filesize 			50M
 #php_value post_max_size 		            55M
 #php_value memory_limit 	               384M
were causing the webserver to set the memory limit to 256K and POST variable not working.
So I commented them out and insted used php.ini to set the variables.
It worked fine after that.

------------------------------------------------------------------------
[2009-09-10 10:53:46] just at helping dot com

IT IS NOT a BUG. GET and post methods will work as normal requests but if you use the form enctype
multipart then you got to handle the request as multipart. In java I use the oreilly
MultipartRequest to parse the data and it works wonderfully. You migh thave to find a way to get it
in PHP or you can write yourself a multipartrequest class based on oreilly's one.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=26004


--
Edit this bug report at https://bugs.php.net/bug.php?id=26004&edit=1


Thread (29 messages)

« previous php.bugs (#222018) next »