FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » download a file after user enters some data in php
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
download a file after user enters some data in php [message #179400] Tue, 16 October 2012 14:21 Go to next message
Nagender is currently offline  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 Go to previous messageGo to next message
The Natural Philosoph is currently offline  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 Go to previous messageGo to next message
Jerry Stuckle is currently offline  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 Go to previous messageGo to next message
Michael Vilain is currently offline  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]
Re: download a file after user enters some data in php [message #179404 is a reply to message #179403] Wed, 17 October 2012 10:46 Go to previous message
Nagender is currently offline  Nagender
Messages: 2
Registered: October 2012
Karma: 0
Junior Member
Thanks for your reply.

I will find a solution with this information.

Thanks and Regards
Nagender.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: test
Next Topic: Code "folding" in NetBeans IDE 7.2
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 18:10:55 GMT 2024

Total time taken to generate the page: 0.02522 seconds