wcbennett3 Posted November 14, 2013 Share Posted November 14, 2013 I am managing a site that has .mp3 files (recordings of talks made in-house) available for streaming. I need to create a way for users to download .mp3s directly, but when they click the link, the audio automatically plays rather than downloads. The link to the file is currently reading another php file, and is set up as follows: <a href="<?php echo get_field('talk_info_talk_audio') ?>">Download the audio</a> Any help is appreciated. ~wb Link to comment https://forums.phpfreaks.com/topic/283898-how-to-create-download-link-with-existing-php/ Share on other sites More sharing options...
gristoi Posted November 14, 2013 Share Posted November 14, 2013 you need to make sure the php that is setting up the mp3 is also setting up the right headers, so that the browser knows what to do with the resource: eg: header ("Content-type: octet/stream"); header ("Content-disposition: attachment; filename=something.mp3;"); header("Content-Length: ".filesize(<size of the file>)); Link to comment https://forums.phpfreaks.com/topic/283898-how-to-create-download-link-with-existing-php/#findComment-1458293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.