473,847 Members | 1,472 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 13287
I think I found the answer under header content type. Sorry. Thanks Oak

"Oak Hall" <oa*@scenicmls. com> wrote in message
news:0a******** ******@news02.r oc.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:\\redoa k\\working\\rec ords\\documents \\';
//documentsin\
// ll be outputting a PDF
header('Content-type: application/pdf');

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

// 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.r oc.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:\\redoa k\\working\\rec ords\\documents \\';
//documentsin\
// ll be outputting a PDF
header('Content-type: application/pdf');

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

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

"Oak Hall" <oa*@scenicmls. com> wrote in message
news:Xc******* *********@news0 2.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******** *************** *************** ***@comcast.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:\\redoa k\\working\\rec ords\\documents \\';
//documentsin\
// ll be outputting a PDF
header('Content-type: application/pdf');

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

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

"Oak Hall" <oa*@scenicmls. com> wrote in message
news:Xc****** **********@news 02.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***** *********@news0 2.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
3998
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 (not the apps form) and perform the necessary actions then give a confirmation when these actions are done then quit.
13
3803
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 non-printing)...in Windows you need the (0x0d 0x0a) pair, if you want a new-line in a text editor. What's the correct way to get this 2-byte sequence into a file? Thanks #include <iostream>
12
2337
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 graph. Right now, the log name is hard coded. The logs are archived each day in the form of say ddmmyy.log and I would like to put a drop down list in the script that would allow my script to run off the "log" picked or default to the current "hard...
6
10257
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 xls file. Any suggestion appreciated. Thanks in advance
9
10634
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". Is there anyway to point to that file and return the information about the file properties? Size, date modified, created, etc? Thanks
4
2297
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 monitor when I give the command print_r which is printed out in a array format. The problem I facing is I want this output in a text file, but I have tried so many things it is not working I am copying my code below, I need help in this urgently....
75
3561
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; char ch; long int a=0;
1
5614
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 execute it using tomcat server5.5. the code is as follows. if you have any other coding regarding this, please send me.it's urgent. import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;
1
1824
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
5887
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 directory. Does anyone know how to open a directory on Win OS so it returns a file descriptor to it.Maybe open should be given another parameters or some other function exists that I don't know of.
0
9889
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10987
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9486
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7885
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5723
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5914
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4535
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 we have to send another system
2
4125
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3166
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.