Jump to content

Displaying php page above document root


calabiyau

Recommended Posts

Well this is part two to a previous question I guess.  I am storing client files above document root for privacy but would like the ability to for each client to view their own files.  These files are basically of three types: html docs, php scripts, and items for download.  I've managed to get the downloads to work as well as the html pages, but the php scripts do not display the echo commands.  Must have something to do with the content type header being text/html but I would've thought that is what the server would output, so it should work, unless i'm really not understanding this.  I've tried other content type headers, but all they do is prompt for a download.  Anybody able to help with this?

 


if ($_GET['action']=='stream')

	{

	ob_get_clean();

	$location = "../ext_client_doc/".$_GET['user']."/".$_GET['doc'];
	$fd = fopen($location, 'rb');


	header("Content-Type: text/html");
//These are the other headers I have tried that prompted a download
	//header("Content-Type: application/x-php");
	//header("Content-Type: application/octet-stream");
	//header("Content-Type: application/x-httpd-php");
	//header("Content-Disposition: inline");


	ob_flush();
    		flush();

         	while(!feof($fd)) {
     
               	$buffer = fread($fd, 2048);
               	print $buffer;
         	}


     
         	fclose ($fd);
    

        	exit;

Link to comment
https://forums.phpfreaks.com/topic/49819-displaying-php-page-above-document-root/
Share on other sites

you can only execute php files with apache inside document_root unless you are including them with include() or require()

 

if you want to execute them outside of root use the cli, if you are using a linux box just add

 

#!/usr/bin/php

 

to the top of the file

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.