I need to POST a Form with DATA from app

Monkey Forums/Monkey Beginners/I need to POST a Form with DATA from app

Prime_8(Posted 2014) [#1]
I need to POST a Form with data from app.

I have a bit of PHP , that is looking to query string values and get data, and that is all fine , but i need the monkey app to be able to send the data back as a attachemnt along with the query part of the URI .

think like a file uploader HTML with a submit button .
like this :
<form action="some.php?user=duede&pass=passW"
enctype="multipart/form-data" method="post">
<p>
Type some text (if you like):<br>
<input type="text" name="textline" size="30">
</p>
<p>
Please specify a file, or a set of files:<br>
<input type="file" name="datafile" size="40">
</p>
<div>
<input type="submit" value="Send">
</div>
</form>


I have been trying to use the brl.httprequest example but the example does not realy show how to say send a fille or buffer of given length .
Is this possible in native Monkey ? and have i just missed a example post / thread ?
I dont want to have to make a native c++ instruction.

the file /or a buffer would usualy be very small nothing big , just some metrics that can't be packed into the query string .


Prime_8(Posted 2014) [#2]
Still trying to figure this out .

The query part of the URI will only be able to have a user , pass , and a 3rd Int like session key like thing .

	Method OnCreate()
	
		get_req = New HttpRequest("GET", "localhost:80/testcont/push_a.php?user=Monkey_8&pass=getOne", Self)
		get_req.Send
		
		post_req = New HttpRequest("POST", "localhost:80/testcont/push_a.php?user=Monkey_8&pass=postOne", Self)
		'need : enctype="multipart/form-data"
		'post_req.SetHeader("enctype", "text/plain")
	'	post_req.SetHeader("MAX_FILE_SIZE", "30000") ' this should set the files size
		' will possibly have to encode to string due to how this module is setup ? , cant send a pure buffer and type it at server 
		post_req.SetHeader("name", "myTest.txt") ' only tells my php it is supposed to be a txt or such
		' type="image/bmp" ?
	'	post_req.SetHeader("type", "image/gif")
		'post_req.SetHeader("type", "text/plain")
		'post_req.SetHeader("submit", "go")
		' post_req.Send("some Bin  encoded to string some how ? like old FTP trick.")
		'or even data and value string ? then CSV could be used. 
		post_req.Send("name=crazyTest")
			
		SetUpdateRate 60
	End


i looked in the module src for HttpRequest , still cant figure out if i'm just using it wrong .

nothing i can do with .Send or .SetHeader will let me add 'data' string or other wise ?
even a CSV type string would do fine .
Most of what i have found in forums seems to stop at just the query part of URI , "?......."

what I'm trying to do is POST as telemetry file with specific User & Pass & SessionNumer values .

so "push_a.php?user=Monkey_8&pass=postOne&sessionnum=" + SessionNumber
then the small telemetry sets each se would be like :
stagename$ , values:int[]

that doe snot lend well to just a query part of URI .


Prime_8(Posted 2014) [#3]
LOL ok i solved it , my $_POST 's were all showing blank at my server . << held me up for days
some how the $_POST gets wiped rite after use .

after some checking in the server CSV is easy to send . i can get it at my PHP side with file_get_contents('php://input');
i should be able to us the overload of post_req.Send
so:
post_req.Send "some,big,CSV,string,that,could,have,162763663763,all,the,telemetry,needed"


so in PHP some place
 // PHP
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$rawdata = file_get_contents('php://input');
echo "This is the content: " . $rawdata ." :". PHP_EOL . "<BR>" ; 
// do what you want with $rawdata parsing wise.
}
?>