Click here to Skip to main content
16,017,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my system I have PDF file for one module. The PDF file is kind of my report.
Once user login into the system, then and only then they can see the content if not login to the system and directly want to access that PDF file URL one can redirect to the login screen.

It works fine, but now my issue is I have one functionality in which I must need to content of PDF file based on the URL (I am already login to my system) So I am trying to use file get content function but it will fetch the login screen content. I have also tried with the stream context create function but still the issue is the same.

What I have tried:

$file = URL of my PDF file;
$_POST['created_by'] = Core::getUserData('id');
$_POST['user_login'] = $_SESSION['user_login'];



$data = $_POST;
//	pre($data,1);
	// use key 'http' even if you send the request to https://...
				$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);
				$fileContent = readfile($file, false, $context);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900