The following code snippet will guide you to implement the php code that will prompt user to download files in his browser window.
<?php
//download.php
//content type
header('Content-type: text/plain');
//open/save dialog box
header('Content-Disposition: attachment; filename="sample.txt"');
//read from server and write to buffer
readfile('test.txt');
?>
<!--List of Content Types
=====================
pdf -- application/pdf
sig -- application/pgp-signature
spl -- application/futuresplash
class -- application/octet-stream
ps -- application/postscript
torrent -- application/x-bittorrent
dvi -- application/x-dvi
gz -- application/x-gzip
pac -- application/x-ns-proxy-autoconfig
swf -- application/x-shockwave-flash
tar.gz -- application/x-tgz
tgz -- application/x-tgz
tar -- application/x-tar
zip -- application/zip
mp3 -- audio/mpeg
m3u -- audio/x-mpegurl
wma -- audio/x-ms-wma
wax -- audio/x-ms-wax
ogg -- audio/x-wav
wav -- audio/x-wav
gif -- image/gif
jpg -- image/jpeg
jpeg -- image/jpeg
png -- image/png
xbm -- image/x-xbitmap
xpm -- image/x-xpixmap
xwd -- image/x-xwindowdump
css -- text/css
html -- text/html
htm -- text/html
js -- text/javascript
asc -- text/plain
c -- text/plain
conf -- text/plain
text -- text/plain
txt -- text/plain
dtd -- text/xml
xml -- text/xml
mpeg -- video/mpeg
mpg -- video/mpeg
mov -- video/quicktime
qt -- video/quicktime
avi -- video/x-msvideo
asf -- video/x-ms-asf
asx -- video/x-ms-asf
wmv -- video/x-ms-wmv
wmp -- video/x-ms-wmp
wvx -- video/x-ms-wvx
wm -- video/x-ms-wm
mp4 -- video/mp4
mpv2,mp2ve -- video/x-mpeg2
rv -- video/vnd.rn-realvideo
fli,flc -- video/fli
3gpp,3gp -- video/3gpp
bz2 -- application/x-bzip
tbz -- application/x-bzip-compressed-tar
tar.bz2 -- application/x-bzip-compressed-tar -->
Labels
Blog Archive
-
▼
2009
(133)
-
▼
September
(19)
- How to Block Websites
- Blog Monitoring methods using Google Analytics
- 7 Reasons to Read the Glorious Quran
- Maruti Suzuki Ritz Specifications | Maruthi Ritz P...
- Get Vodafone Caller Tunes for Free
- Smallest Nokia Cell Phone In the World
- How to recover lost EXCEL password
- How to View Locked Album photo and scrapbook of an...
- Tips to prevent your Orkut Account
- 10 things you should know about Nokia
- Plane crashes cost insurers over $1 bn in 2009
- NASA unveils first images from revamped Hubble
- US man to run 5,000 km barefoot
- How to Install Google ads under posts
- What will happen to your online life after you die?
- How to Download files in php
- How to rename multiple files in a directory with php
- How to fix php warning – "Cannot modify header inf...
- The best and worst way of saying the things
-
▼
September
(19)
0 comments:
Post a Comment