Hi All,
 
I feel almost ashamed for having to ask this question. Mostlly because I
know it's been asked so many tmes but I just don't seem to be able to get it
working. I want to secure some files from viewing by putting them in a
different folder than the document root. Then, through a simple Content
class output them to the browser, and of course have this browser display
the page correctly. This file comes from an admin user upload, and can be of
any time. pdf, doc, jpg, xls, well .. don't need to name all existing file
extensions, do I? And I just know the answer has been given in a previous
post, which I just cannot find on the archives.
 
Here's the deal:
 
    110         $File = $this->Get($User);
    111
    112         foreach($File['Headers'] as $H) header($H);;
    113         readfile($File['Path']);

Which I think is perfectly valid code for outputting this file. Now, several
examples of what $File will contain after the call to $this->Get($User) ;)

1: Array
(
    [Headers] => Array
        (
            [0] => Content-Type: image/pjpeg
            [1] => Content-Disposition: attachment; filename="duuude.jpg"
            [2] => Accept-Ranges: bytes
            [3] => Conent-Length: 23256
        )

    [Path] => /home/wouter/projects/mspa.nl/files/duuude.jpg
)


1: Array
(
    [Headers] => Array
        (
            [0] => Content-Type: application/msword
            [1] => Content-Disposition: attachment;
filename="Modulehandleiding.doc"
            [2] => Accept-Ranges: bytes
            [3] => Conent-Length: 156672
        )

    [Path] => /home/wouter/projects/mspa.nl/files/Modulehandleiding.doc
)


1: Array
(
    [Headers] => Array
        (
            [0] => Content-Type: application/pdf
            [1] => Content-Disposition: attachment;
filename="Interviewschema.pdf"
            [2] => Accept-Ranges: bytes
            [3] => Conent-Length: 40141
        )

    [Path] => /home/wouter/projects/mspa.nl/files/Interviewschema.pdf
)

As for the first one, it works. It shows me the image on my screen .. The
word document and pdf file are shown as they would look like if they're
opened in notepad or such.

Any help is widely appriciated .. ;)
Wouter

Ps. To clearify: $this is the internal instance of my Content class, $User
is passed onto the function to check if he is allowed to view the content.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to