download a file after user enters some data in php [message #179400] |
Tue, 16 October 2012 14:21 |
Nagender
Messages: 2 Registered: October 2012
Karma: 0
|
Junior Member |
|
|
Hi to all,
In my working website user has to download a pdf file once he submits some information.
No hyperlinks has to show directly file has to download.
I have the idea using hyperlink, that means once user enter details ,it will redirects to another page.
this is not case.
It has to download there it self.
Please any one has idea, let help me.
I am searching for this since last 4-5 hr's.
|
|
|
Re: download a file after user enters some data in php [message #179401 is a reply to message #179400] |
Tue, 16 October 2012 14:27 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Nagender wrote:
> Hi to all,
> In my working website user has to download a pdf file once he submits some information.
> No hyperlinks has to show directly file has to download.
>
> I have the idea using hyperlink, that means once user enter details ,it will redirects to another page.
> this is not case.
> It has to download there it self.
>
Do you mean you want to go to another page after downloading?
> Please any one has idea, let help me.
> I am searching for this since last 4-5 hr's.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|
Re: download a file after user enters some data in php [message #179402 is a reply to message #179400] |
Tue, 16 October 2012 16:15 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 10/16/2012 10:21 AM, Nagender wrote:
> Hi to all,
> In my working website user has to download a pdf file once he submits some information.
> No hyperlinks has to show directly file has to download.
>
> I have the idea using hyperlink, that means once user enter details ,it will redirects to another page.
> this is not case.
> It has to download there it self.
>
> Please any one has idea, let help me.
> I am searching for this since last 4-5 hr's.
>
OK, so in order to submit the information, the user has to submit a
form. When he/she submits the form, it goes to a PHP script on your
page which validates the inputted data. If the data is valid, it then
sends the file to the user, with the appropriate headers, i.e.
(Off the top of my head - not checked for syntax):
// $filename contains the complete path and filename of the pdf to send
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename='".basename($filename)
.."'");
header("Content-Length: " . filesize($filename)); // Optional but nice
readfile("$filename");
Note: ensure NOTHING (including white space) is sent before these calls.
You can get more examples from the manual at php.net, look at the
header() function.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: download a file after user enters some data in php [message #179403 is a reply to message #179400] |
Tue, 16 October 2012 16:46 |
Michael Vilain
Messages: 88 Registered: September 2010
Karma: 0
|
Member |
|
|
In article <79a88c4d-32a2-4545-86d3-02ec367f365f(at)googlegroups(dot)com>,
Nagender <nagender(dot)goldenslash(at)gmail(dot)com> wrote:
> Hi to all,
> In my working website user has to download a pdf file once he submits some
> information.
> No hyperlinks has to show directly file has to download.
>
> I have the idea using hyperlink, that means once user enter details ,it will
> redirects to another page.
> this is not case.
> It has to download there it self.
>
> Please any one has idea, let help me.
> I am searching for this since last 4-5 hr's.
I'm not sure, based on your broken english, what you're trying to do.
You have a form that the user fills out. Then clicks SUBMIT.
And you want that form to download a PDF file to the user's browser? Or
do you want to display a page that has a link where the user can
download the PDF file? Or something else?
Doing an automatic download is pretty simple once php has control of
interaction, which it will after you click SUBMIT. Send the proper
header, mime-type, then open the PDF file you want to send and output it
to the browser as a binary file.
--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
|
|
|
|