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
Return to the default flat view Create a new topic Submit Reply
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 previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
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
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: test
Next Topic: Code "folding" in NetBeans IDE 7.2
Goto Forum:
  

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

Current Time: Wed Nov 27 08:46:38 GMT 2024

Total time taken to generate the page: 0.04829 seconds