Value of POST variable disappearing in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xtempore
Forum Newbie
Posts: 3
Joined: Fri Jul 10, 2009 5:37 am

Value of POST variable disappearing in PHP

Post by xtempore »

This is a weird one.

I have a Flex app which posts some data to PHP via an HTTP post. In the development environment it worked perfectly, in one client's site it works fine, but not on anothers.

The HTTP post has 3 variables, type, name and data.

type and name are just short text fields and work fine.

data is binary but is base64-encoded, and normally works fine, but on this new client set-up it stops working when the data gets to about 48K.

I used the Live HTTP Headers in Firefox, and can see that the data is definitely being sent, but when trying to access it in PHP it gets...
Notice: Undefined index: data in /server.php on line 67

48K doesn't seem like it should be breaking any limits, and the fact that it works with larger data on other setups makes me think it is a config thing, but what...?

:banghead:

Any ideas appreciated!
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: Value of POST variable disappearing in PHP

Post by jazz090 »

this kind of error usually happens when you are sending via GET, you should really double check that it is POST you are using. my personal experience with flex is that its easy to mix up GET and POST in that environment. and may i suggest that if you are sending binary files, instead of encoding them via base64, just use the FileSystem built in AS3 (my assumption being a user is uploading a file) which will facilitate this at much ease.
xtempore
Forum Newbie
Posts: 3
Joined: Fri Jul 10, 2009 5:37 am

Re: Value of POST variable disappearing in PHP

Post by xtempore »

It is definitely a POST. I just double checked using the Live Headers to be sure.

The data is actually bitmap created by the application. When the user presses [Save] the data is converted to JPEG and sent to the server.

The crazy thing is that I have to send the data to the server, just so that the server can send it back again as a file. It'd be great to find an alternative way of doing this, but my understanding of browser limitations is that it can only save a file that has been downloaded, and has no way to save one generated on the client side.

But back to my original question... Does anyone else have any ideas why the data variable disappears?
xtempore
Forum Newbie
Posts: 3
Joined: Fri Jul 10, 2009 5:37 am

Re: Value of POST variable disappearing in PHP

Post by xtempore »

I think I've figured it out.

One word --- "suhosin"

The problem server uses suhosin. In particular the problem is the setting of suhosin.post.max_value_length (default = 65000).

Actually even after increasing suhosin.post.max_value_length I was still getting the problem. In the end I used suhosin.simulation = On

Once I set that in the php.ini things started working again.

I hope someone else finds this useful, and doesn't spend too many hours banging their head against the wall as I did!
Post Reply