473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Force a file to download using php

17
I have a html file on my server, if a user clicks on a link it should download, but instead it opens up in browser window

coding for downloading

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo $todayis = date("l, F j, Y.") ;
  3.  
  4. $id1 = $_POST['id'];
  5. header('Cache-Control: public');
  6. header('Content-Description: File Transfer');
  7. header('Content-disposition: attachment; filename=pm/'.$id1.'.html');
  8. header('Content-type: application/force-download');
  9. header('Content-Transfer-Encoding: binary');
  10. readfile('pm/'.$id1.'.html');    
  11. ?>
Its work fine in localhost but in server it opens up in new browser window, Any help would be useful

Regards
Zabiullah
Mar 25 '11 #1
1 2015
johny10151981
1,059 1GB
follow the link. It might help you

and @ use before readfile() function
Mar 26 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Navin | last post by:
hi, guys i am using the following code to force a file download dialog in asp Response.ContentType = "application/vnd.ms-excel" response.AddHeader "content-disposition","attachment; filename="...
1
by: Navin | last post by:
hi, guys i am using the following code to force a file download dialog in asp Response.ContentType = "application/vnd.ms-excel" response.AddHeader "content-disposition","attachment; filename="...
3
by: BOHICA | last post by:
I would like on my page when users click one of my mp3 files for the dialog box to pop up so they can choose to save the file to disk instead of trying to open through IE, but the dang thing won't...
1
by: Yanick | last post by:
Hi all, I'm creating an application for our needs and I want to make something using JavaScript, but I don't know how. Hope somebody will be able to give me hints on this. When I click on a...
4
by: Kevin Muenzler, WB5RUE | last post by:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of...
2
by: Ole Hanson | last post by:
Hi It seems to be virtually impossible to perform a download of more than 2 files at the time from any website? The same limitation seems to be put on IE, if I'm using that as Client. I want...
0
by: karups | last post by:
hi, Can some one help me out? How to Force file download box when clicking on a link for a .pdf file. Normally it opens the pdf in IE itself, instead it should ask for (open , save and...
4
by: L. Scott M. | last post by:
I am invoking a file download using the following code: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + downloadFile.Name);...
2
by: skulka3 | last post by:
Hello, I want to implement file downloads inside an authenticated web page, such that when a user clicks a link, the server side python code connects to a ftp server, downloads a relevant file...
6
by: ziycon | last post by:
I'm wondering if its possible to force a file to be downloaded when you go to a certain page. Say if you click on the link for the page and then it will go to that page and give you the prompt box to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.