...

View Full Version : Download on Access



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

aedrin
11-14-2007, 09:55 PM
http://php.net/header

Cerby
11-14-2007, 09: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?

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

Cerby
11-14-2007, 10:04 PM
Like What?

Cerby
11-14-2007, 10: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"');
?>

aedrin
11-14-2007, 10: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?

Cerby
11-14-2007, 10: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?


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

aedrin
11-14-2007, 10: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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum