samScripts.com
[Home] [My Scripts] [Contact] [Business Card Designer] [Donate] [$8.95 Domain Names]

Home > Scripts > File downloads

File downloads

... feel free to use this script for whatever you like.

File downloads

A short snippet for downloading files.

Description:

The following bit of code should cause most browsers to pop up a file download dialog box.<br><br>
To use it, place it in a script then put a link on your webpage pointing to it:

Code:
<?php

$filename
= "name of the file to download";
$filepath = "path/where/file/is/on/server/";

header("Content-type: application/octetstream");
header("Content-Disposition: attachment; filename=$filename");

readfile("$filepath$filename");

exit();

?>


Note: There should be no blank lines or html outside the php for this script.

[Back] [Top] [Forward]

Powered by php, mySql.

Request processed in 0.01 seconds on Wednesday 26th September 2012 23:43:11.

©2002 Sam Yapp

What do you think of my resume wizard site? All nicely written in php :)