
Markie
Posts: 251
|
Posted: 04/17/2008, 11:46 PM |
|
Normally, when you add a link to a file (such as .jpg, .pdf, .mp3, .avi etc.) and visitors click this link, the file will open in their standard web browser or with their standard media player. If you want to offer your visitors the option to download the file, you can take this steps:
Add a link on your webpage with this details:
-----
Static text: Download
Static address: download.php
Parameters:
Source Type: Datasource Column
Parameter source: (column with download details in your MySQL table, like the URL of the file)
Parameter name: file
Source Type: Datasource Column
Parameter source: (column with filename in your MySQL table)
Parameter name: filename
-----
Make a new page, named download.php, and add this code to the top of this page:
-----
<?php
$file = $_GET['file'];
$filename = $_GET['filename'];
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$filename.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
-----
Just my two cents,
Markie
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
|

|
|
|
|