File downloading from URL, indicating requests from GET and POST
-
I'm downloading the file with PHP:
<?php $url = 'http://site.ru/index.php?request=A;' header('Content-Type: application/force-download'); header('Content-disposition: inline; filename="'.basename($url).'"'); copy($url, 'gosloto.html'); ?>
As you can see, I've indicated a request for download.
$_GET['request'] = 'A'
(in the first lineindex.php?request=A;
)As far as possible
$_POST
?
-
There's a couple of methods.
No. 1
$url = 'http://site.ru/index.php'; $myvars = 'request=A';
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);$response = curl_exec( $ch );
output
$response
http://php.net/manual/ru/function.curl-exec.php https://stackoverflow.com/a/3080222/4953620
No. 2
$url = 'http://site.ru/index.php';
$data = array('request' => 'A', 'request2' => 'B');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
)
);$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
http://php.net/manual/ru/function.file-get-contents.php https://stackoverflow.com/a/23385319/4953620
No3
<?php
$fields = array(
'request' => 'А',
'pass' => 'se_ret'
);
$files = array(
array(
'name' => 'uimg',
'type' => 'image/jpeg',
'file' => './profile.jpg',
)
);$response = http_post_fields("http://site.ru/index.php", $fields, $files);
?>
This example also sends the file. http://php.net/manual/ru/function.http-post-fields.php )