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 :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
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 10:21 Go to next message
Nagender is currently offline  Nagender
Messages: 2
Registered: October 2012
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 10: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
add to buddy list
ignore all messages by this user
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 12:15 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 12:46 Go to previous messageGo to next message
Michael Vilain is currently offline  Michael Vilain
Messages: 88
Registered: September 2010
Karma: 0
Member
add to buddy list
ignore all messages by this user
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 06:46 Go to previous message
Nagender is currently offline  Nagender
Messages: 2
Registered: October 2012
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Thanks for your reply.

I will find a solution with this information.

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

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

Current Time: Sun Dec 17 18:20:18 EST 2017

Total time taken to generate the page: 0.00580 seconds