无法获取文件的内容

无法获取文件的内容

本文介绍了无法获取文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的系统中,我有一个模块的PDF文件。 PDF文件是我的报告。

一旦用户登录系统,然后他们就可以看到内容,如果没有登录系统,直接想要访问该PDF文件的URL,可以重定向到登录界面。



它工作正常,但现在我的问题是我有一个功能,我必须根据URL(我已经登录到我的系统)需要PDF文件的内容所以我正在尝试使用文件获取内容功能,但它将获取登录屏幕内容。我也试过了流上下文创建功能,但问题仍然是一样。



我尝试了什么:



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);

推荐答案




这篇关于无法获取文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:38