469,353 Members | 2,053 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

Return a file

I have files (pdf) that users can view. They are in a protected site.

index.php's first function is to check the User Name and password. If they
are ok, it answers the request.

I want return a pfd file.

So if a user goes to
http://www.mysite.com/index.php?comm...file=mydoc.pdf

Index.php would check there user name and password then return the pdf file
to the borwser. Can this be done??

Thanks
Oak
Aug 12 '05 #1
5 12998
I think I found the answer under header content type. Sorry. Thanks Oak

"Oak Hall" <oa*@scenicmls.com> wrote in message
news:0a**************@news02.roc.ny...
I have files (pdf) that users can view. They are in a protected site.

index.php's first function is to check the User Name and password. If they
are ok, it answers the request.

I want return a pfd file.

So if a user goes to
http://www.mysite.com/index.php?comm...file=mydoc.pdf

Index.php would check there user name and password then return the pdf
file to the borwser. Can this be done??

Thanks
Oak

Aug 12 '05 #2
I use the example, and get a return of garbage. If the content header not
being understood??
Thanks
Oak

Function view($qq)
{
$dir='c:\\redoak\\working\\records\\documents\\';
//documentsin\
// ll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="download"');

// The PDF source is in original.pdf
readfile($dir.$qq['file']);
}

"Oak Hall" <oa*@scenicmls.com> wrote in message
news:Xc****************@news02.roc.ny...
I think I found the answer under header content type. Sorry. Thanks Oak

"Oak Hall" <oa*@scenicmls.com> wrote in message
news:0a**************@news02.roc.ny...
I have files (pdf) that users can view. They are in a protected site.

index.php's first function is to check the User Name and password. If
they are ok, it answers the request.

I want return a pfd file.

So if a user goes to
http://www.mysite.com/index.php?comm...file=mydoc.pdf

Index.php would check there user name and password then return the pdf
file to the borwser. Can this be done??

Thanks
Oak


Aug 12 '05 #3
Oak Hall wrote:
I use the example, and get a return of garbage. If the content header not
being understood??
Thanks
Oak

Function view($qq)
{
$dir='c:\\redoak\\working\\records\\documents\\';
//documentsin\
// ll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="download"');

// The PDF source is in original.pdf
readfile($dir.$qq['file']);
}

"Oak Hall" <oa*@scenicmls.com> wrote in message
news:Xc****************@news02.roc.ny...

I think I found the answer under header content type. Sorry. Thanks Oak

"Oak Hall" <oa*@scenicmls.com> wrote in message
news:0a**************@news02.roc.ny...

I have files (pdf) that users can view. They are in a protected site.

index.php's first function is to check the User Name and password. If
they are ok, it answers the request.

I want return a pfd file.

So if a user goes to
http://www.mysite.com/index.php?comm...file=mydoc.pdf

Index.php would check there user name and password then return the pdf
file to the borwser. Can this be done??

Thanks
Oak



Here's what I use to accomplish the exact same thing (I'm pretty sure
that I copied and pasted this from somewhere else):

<?php
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
?>

--
*****************************
Chuck Anderson Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Aug 12 '05 #4

"Chuck Anderson" <we************@seemy.sig> wrote in message
news:MZ*****************************************@c omcast.com...
Oak Hall wrote:
I use the example, and get a return of garbage. If the content header not
being understood??
Thanks
Oak

Function view($qq)
{
$dir='c:\\redoak\\working\\records\\documents\\';
//documentsin\
// ll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="download"');

// The PDF source is in original.pdf
readfile($dir.$qq['file']);
}

"Oak Hall" <oa*@scenicmls.com> wrote in message
news:Xc****************@news02.roc.ny...
I think I found the answer under header content type. Sorry. Thanks Oak

"Oak Hall" <oa*@scenicmls.com> wrote in message
news:0a**************@news02.roc.ny...

I have files (pdf) that users can view. They are in a protected site.

index.php's first function is to check the User Name and password. If
they are ok, it answers the request.

I want return a pfd file.

So if a user goes to
http://www.mysite.com/index.php?comm...file=mydoc.pdf

Index.php would check there user name and password then return the pdf
file to the borwser. Can this be done??

Thanks
Oak


Here's what I use to accomplish the exact same thing (I'm pretty sure that
I copied and pasted this from somewhere else):

<?php
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
?>

--
*****************************
Chuck Anderson Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************


This works THANKS! but it wants to download the pdf. How do I have it open
in the borwser plugin??
Aug 12 '05 #5
Oak Hall wrote:
How do I have it open in the borwser plugin??


I'd configure my own browser to associate application/pdf with
whatever plugin I had in mind and then have it present the PDF
to me 'inline'.

[There's a hint there, if you find yourself heading down the
rickety Content-Disposition road: 'inline' means something
different to 'attachment'. But you never heard that from me,
ok?]

--
Jock
Aug 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Paul | last post: by
13 posts views Thread by J. Campbell | last post: by
12 posts views Thread by Mike Brashars | last post: by
6 posts views Thread by Clint Stowers | last post: by
75 posts views Thread by ume$h | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.