View Full Version : Download on Access

11-14-2007, 08:49 PM
Using PHP, how do I display the download dialog, in order to download a file, upon a page being accessed?

11-14-2007, 08:55 PM

11-14-2007, 08:59 PM
So I need to use?:

header('Content-Disposition: attachment; filename="downloaded.pdf"');

How do I use a path from a database, as the filename?

11-14-2007, 09:02 PM
Just concatenate the variable into the string.

11-14-2007, 09:04 PM
Like What?

11-14-2007, 09:09 PM
Why doesn't the following code work?
I get the following error message:

Parse error: syntax error, unexpected T_STRING in C:\Documents and Settings\Dale Piper\Desktop\Xampp\htdocs\Download.php on line 2

<?php// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="Upload/1.mp3"');

11-14-2007, 09:09 PM
Exactly. Do some more basic PHP before you just ask for code snippets. Have you tried anything yourself? Or are you just copying scripts and changing numbers?

11-14-2007, 09:17 PM
Why Doesn't This Work?

The following code displays a download dialog box, but offers to download/save the php file, not the mp3. How do I download the mp3 file?

header('Content-Type: application/force-download; filename="Upload/1.mp3');

11-14-2007, 09:56 PM
Header does one thing, it tells the browser something. It doesn't modify what you output.

This is what you need to do (in psuedo code):

tell browser to expect an mp3
tell browser to show user a file download box
output mp3 contents

11-14-2007, 10:19 PM
I know that, but how?

11-15-2007, 01:22 AM
Lookup the "Content-type" header.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum