-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
30 lines (29 loc) · 1.16 KB
/
example.php
File metadata and controls
30 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
define('TYPE','binary'); //possible values: binary,path
$s = curl_init();
curl_setopt($s,CURLOPT_URL,'http://localhost/index.php?type='.TYPE);
curl_setopt($s,CURLOPT_RETURNTRANSFER,true);
curl_setopt($s,CURLOPT_POST,true);
curl_setopt($s,CURLOPT_POSTFIELDS,array(
'file'=>'@'.realpath(dirname(__FILE__).DIRECTORY_SEPARATOR.'example.pdf'),
'name' => 'Aaron Lozier',
'email' => 'aaron@informationarchitech.com',
'checkbox 1' => 'Yes',
'checkbox 2' => 0,
'radio 1' => 2,
));
$resp = (curl_exec($s));
$binary = $resp;
curl_close($s);
switch(TYPE){
case 'path':
echo '<a href="'.$binary.'" target="_blank">'.$binary.'</a>';
break;
default:
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="pdf_'.time().'.pdf"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
echo $binary;
break;
}