membership call is preventing readfile() somehow
3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 14, 2014 (RSS)
By markr - August 6, 2014
This readfile() procedure works fine until I add the viewer and login lines for membership. Then the file become corrupted (or something) and won't display.
Can you think of why securing the page is messing with the latter code? See any options I could try to unfetter the readfile() ?
require_once '/myhost/public_html/cmsAdmin/lib/viewer_functions.php';
if (!$CURRENT_USER) {websiteLogin_redirectToLogin();}
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
} // endif
By markr - August 7, 2014
I removed the login requirement and just loaded the viewer and have the same problem.
It if matters, this topic can therefore be moved to the general forum.
Btw, I'm using the readfile() snippet in order to load a file stored in directory above public_html. Like I wrote, it works great until I load the viewer.
Hi Markr,
Is an error message displayed at all?
I'm wondering if the server can't add the headers, as the page has already started loading. This can happen if you have any white space between your PHP opening tag and the start of the document, for example:
<?php //white space at start of document
as opposed to
<?php // no white space at start
Thanks!
Greg
PHP Programmer - interactivetools.com