[Gllug] PHP - no visible directory

Alain Williams addw at phcomp.co.uk
Tue Nov 21 23:41:40 UTC 2006


On Tue, Nov 21, 2006 at 11:31:48PM +0000, ft wrote:
> Hello, 
> 
> I have a problem/question with PHP. 
> 
> if you download a file, you click on a html-link. For the client, the
> structure of the directories are visible.
> 
> Is there a solution, to make it invisible, so that the client don't see
> the directories? 
> 
> html-link on the website
> <a href="index.php?file=file.pdf">Link for download</a>
> 
> PHP-script
> <?
> $dir = "./dir1/dir2/";
> $download = $dir.$file;
> # What is the command, to send the file to the client?

You need to set the content (mime) type & then send the data, eg:
	header('Content-type: application/pdf');
	readfile($download);

I assume that you will validate $file before you do this.

> ?>
> 
> Franz Timmer

-- 
Alain Williams
Parliament Hill Computers Ltd.
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/

#include <std_disclaimer.h>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list