473,511 Members | 9,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13269
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3986
by: Paul | last post by:
Hi, Does anyone know how I would be able to drag a single file onto my applications icon and have it run some predefined code. What I want is to drop an .mp3 file onto my applications icon...
13
3773
by: J. Campbell | last post by:
I'm wanting to output a text header file in front of the data portion of an output file. However when I use "\n" or "endl" as end of line, it just puts a 0x0a in the file(which is...
12
2301
by: Mike Brashars | last post by:
Hi all, I have been searching for a week and am unable to find and example to "Populate picklist from directory and return file name". I have a php script that reads a log file and plots a...
6
10240
by: Clint Stowers | last post by:
Using Acc2k Can anyone suggest some sample code for returning the date of a Linked File? I am linking MyFile.xls as tblMyFile. Simply put, somewhere on a form I would like to the date of the...
9
10541
by: AP | last post by:
Is there anyway to determine what the modified or create date is for a file? In my example I am uploading a text file using the following to select the filename: GetOpenFileName Lib "COMDLG32.DLL"....
4
2278
by: tasahmed | last post by:
Hello Friends, I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the...
75
3468
by: ume$h | last post by:
/* I wrote the following program to calculate no. of 'a' in the file c:/1.txt but it fails to give appropriate result. What is wrong with it? */ #include"stdio.h" int main(void) { FILE *f;...
1
5563
by: shyaminf | last post by:
hi everybody! iam facing a problem with the transfer of file using servlet programming. i have a code for uploading a file. but i'm unable to execute it using tomcat5.5 server. kindly help me how to...
1
1807
by: yanni127 | last post by:
hi everyone I've got a file : fstream in ("f.in"); after searching, file pointer is at the end of file and I wanna return it to the begginnig for other tasks. what statement can I use?
3
5860
by: paleman | last post by:
Hi. I'm trying to write my own version of opendir function on Windows XP.Within that function I'm calling open function: fd = open(path, O_RDONLY, 0); and this fails when path points to a...
0
7251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.