Decoding form post data

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
danc81
Forum Newbie
Posts: 16
Joined: Mon May 11, 2009 2:00 pm

Decoding form post data

Post by danc81 »

Hi,

I'm using php://input to read incoming form data and would just like to know if there's a built-in way to decode the incoming data on the fly before I start writing my own parser. I can't use $_FILES[] due to the size of the incoming data and the fact that I have to run some processes on the data.

I accept incoming post data from another source which is not encoded and I can process it fine but I now have to be able to accept files posted from HTML forms and run the same process on the data.

Is there any simple way to decode the incoming form into fields/file data as I go?

Thanks.
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: Decoding form post data

Post by akuji36 »

Try this:

forms using post

http://blog.themeforest.net/screencasts ... php-day-7/

and regex(regular expressions for php)

http://www.phpvideotutorials.com/regex/
danc81
Forum Newbie
Posts: 16
Joined: Mon May 11, 2009 2:00 pm

Re: Decoding form post data

Post by danc81 »

Thanks for the links.

I can parse a simple form (just text fields) quite easily but my issue is extracting the form fields from the start of the post to get the filename and other form fields and then detect the end of the file (which could be any size from 1MB to 3GB so it's not feasible to have the data in memory). I'm processing in chunks of 64kb and in an ideal world when a boundary is always in a single block I can jus tuser strpos to find the boundary but the issue is when the boundary can cross incoming chunk boundaries. I am trying to find a way which is not too intensive and I think regex would be overkill in this instance. I was hoping there would be some function that I'd missed which would help me out but if not, I'll get started on a parser.

Thanks
Post Reply