473,811 Members | 3,811 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 13286
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
3995
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
3800
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
2335
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
10255
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
10627
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
3560
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
5612
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
1819
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
5883
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
9724
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
10379
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10394
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9201
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...
0
6882
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4336
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
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.