What I am trying to achieve is:
I have a web site to which I have full source code access. The pages in this web site has been created using velocity templates and I have a page with the following form.
<h3>form data</h3>
<form action="$portalPath/test" method="post">
<input type="text" name="text" value="$!self.getTextFromFormData()" />
<input type="submit" />
</form>
Now from another application written in php, I want to make an http request to this page and get a file downloaded. (Which is an html file). To do that, I wrote following code from the other web application :
$url = 'http://localhost/portal/default/test';
$data = array('filename.html');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded
",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
But the result shows the html source of the template I access(i.e. test) and not the html file I want to download. What I want to do is to make an http request to auto enter the file name to the form and make the form auto submit the request and process it and get the required html file downloaded as the result. I don't know if this is possible or if possible whether this is the correct way. If this can be done using curl, that's better. Any idea will be highly appreciated.