-2

I have a webpage where I have links to the photographs and information regarding this being stored in MySQL. Now if I want to add a download button for images/audio, how do I do that, using PHP?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Kraken
  • 23,393
  • 37
  • 102
  • 162
  • i have no idea. any bit of the solution will work. any link to the solution. – Kraken Jul 04 '11 at 07:20
  • 1
    clue: http://stackoverflow.com/questions/1968106/generate-download-file-link-in-php – tradyblix Jul 04 '11 at 07:22
  • 2
    You really haven't provided enough information to provide an answer, short of writing your application for you. You'll need a button, or some other HTML element that resembles a button, that links to some action in your PHP script. You're going to need to show more information if you expect a useful answer. We're here to help you solve _problems_, not to do your work for you. – Jonathan Hall Jul 04 '11 at 07:23

1 Answers1

3

Assuming each file has an ID in the database as well, simply have your download button link to a php page which is setup like this:

<?php 

//$file = fetch file data from db based off of $_GET['id']

header("Content-Type: application/force-download"); 
header('Content-Description: File Transfer'); 

readfile($file);
AlienWebguy
  • 76,997
  • 17
  • 122
  • 145