Welcome Guest, Not a member yet? Register   Sign In
files that can only be accessed when user is logged in - How to implement?
#21

[eluser]louis w[/eluser]
Are you doing these two steps?

Code:
header('Content-Length: '. filesize($load_path));
header('Content-type: '. get_mime_by_extension($load_path));
//get_mime_by_extension requires the file helper to be loaded



Also make sure you are not outputting anything (like the output profiler, or debug code) on the page.
#22

[eluser]deco10[/eluser]
Ok, I added the file helper, thanks for that Smile
It says the image can't be displayed because it contains errors, then the rest of the page doesn't load.
#23

[eluser]louis w[/eluser]
Could you post your code and/or show example site?
#24

[eluser]deco10[/eluser]
I will post some code, just need a few minutes to get the relevant pieces together

Where should I be putting the header() code though?
#25

[eluser]deco10[/eluser]
I'm not really sure what else you need to see. this is the view file.

If I look at the image source (which Chrome allows me to do) it says the source of the image is:

http://www.mysite.com/dev/site6/index.php/home/dealer


.....\httpdocs\dev\site6\system\application\views
view.php
Code:
<html>
<head></head>


<body>
<?

$load_path = $_SERVER[‘DOCUMENT_ROOT’] . “/dev/site6/assets/secure_content/wk.png”;
header(‘Last-Modified: ‘.gmdate(‘D, d M Y H:i:s’, filemtime($load_path)).’ GMT’);
header(‘Content-Length: ‘. filesize($load_path));
header(‘Content-type: ‘. get_mime_by_extension($load_path));
readfile($load_path);

?>






</body>
</html>
#26

[eluser]deco10[/eluser]
Actually, I'm wondering if we had a large misunderstanding. I don't want the users to download pictures (just pdf's). I want the pictures to display on the web page as they would normally. It looks like using headers and readfile is trying to load it in its own page.
#27

[eluser]louis w[/eluser]
Yes your right, readfile loads a file's contents into the output buffer.

The only way to load an image inline like you are trying to do would be to base64 encode it's contents. This is very tricky and has problems in IE. I can't offer any help on how to do that, I would try googleing it.
#28

[eluser]deco10[/eluser]
I could cheat and just copy the image to a new randomly named folder when the users asks for then delete it after Tongue
#29

[eluser]louis w[/eluser]
Or you could generate a random token which you store in the database and place it in the url to the dynamic image. After retrieval delete it from the db so it can't be used again.




Theme © iAndrew 2016 - Forum software by © MyBB