Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 2nd, 2007, 01:13 AM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with downloading with php..pls help urgent

Hi
I am developing a page on which I am downloading the files using php.and on the same page i have another submit button. After downloading any file when i write something and press submit button the donwloading dialog opens automatically. I have used all codes for cache but nort working.
pls help me
here is the code to download a file
$file='a.doc';/// for example
$ext='doc';/// for example
header("Content-type: application/$ext");
header("Content-Disposition: attachment; filename=$file");
readfile($file);
exit;

after downloading as soon as i press the submit button this code generates again.


pls help urgent
thanks

Reply With Quote
  #2 (permalink)  
Old November 9th, 2007, 01:48 AM
Registered User
 
Join Date: Nov 2007
Location: Gampaha, , Sri Lanka.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to asanga
Default

it works but this code should be in the top of the page
<?php
$file='a.doc';/// for example
$ext='doc';/// for example
header("Content-type: application/$ext");
header("Content-Disposition: attachment; filename=$file");
readfile($file);
exit;
?>
there shouldn't be any blank line before the code

Asanga Amarawansa
asanga@needmatch.biz
http://www.needmatch.biz
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can any one help me pls Urgent..? venkatu2005 ASP.NET 1.0 and 1.1 Basics 1 April 8th, 2008 08:45 AM
PHP with IFRAME..pls help me its URGENT raaj Beginning PHP 2 February 26th, 2007 02:12 AM
Downloading files using JSP...Urgent!! Bhimashankarkulkarni Javascript 2 March 1st, 2005 04:42 AM
datagrid problem urgent pls. dsmportal Pro VB.NET 2002/2003 0 February 7th, 2005 08:00 PM



All times are GMT -4. The time now is 08:24 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.