Downloading

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
daebat
Forum Commoner
Posts: 47
Joined: Mon May 11, 2009 10:16 am

Downloading

Post by daebat »

I am posting different versions of design files and I need for the files to create a pop up save dialog and not open with the default program (usually quicktime grrr). How can I do this?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Downloading

Post by Eran »

daebat
Forum Commoner
Posts: 47
Joined: Mon May 11, 2009 10:16 am

Re: Downloading

Post by daebat »

What if I'm pulling these files from the database? Here is an example of my code:

Code: Select all

$data = mysql_query("SELECT * FROM postcards ORDER BY id DESC ") or die(mysql_error());
 
 
while($info = mysql_fetch_array( $data ))
 
Echo "<tr><td style='vertical-align: middle; text-align:center;font-size:x-small;'>Open InDesign Files</td><td><a href='upload/postcards/".$info['zip'] . "'><img src='../associates/images/download.png' border='0' width='75'></a><br></td></tr>";
 
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Downloading

Post by Eran »

Instead of linking directly to the media, you need to link to a download script that will stream it with the forced download headers, as is shown in the link I provided.
daebat
Forum Commoner
Posts: 47
Joined: Mon May 11, 2009 10:16 am

Re: Downloading

Post by daebat »

So should I just replace:

Code: Select all

<?PHP
    // Define the path to file
    $file = 'ryboe_tag_cloud.zip';
?>
 
with:

Code: Select all

<?PHP
    // Define the path to file
    $file = $info;
?>
 
?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Downloading

Post by Eran »

Pass the filename as a parameter to the script through the URL and use that parameter instead of the filename in example as you suggested.
Post Reply