472,145 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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 13162
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
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.