šŸŒ“

Customize a download with PHP This code is really useful to download files (i.e. an mp3 file). It will tell the browser about the file type you’re about to download while also customizing the file name of it: header('Content-type: audio/mpeg'); header('Content-Disposition: attachment; filename="'.$name.'.mp3"'); readfile($link); Now we just need to provide the $name and $link variables for it to work. This […]

by
on August 30, 2008
(0 minute read)

This code is really useful to download files (i.e. an mp3 file). It will tell the browser about the file type you’re about to download while also customizing the file name of it:

Please donate to keep this server up

header('Content-type: audio/mpeg');
header('Content-Disposition: attachment; filename="'.$name.'.mp3"');
readfile($link);

Things Iā€™m buying on Amazon this week

Now we just need to provide the $name and $link variables for it to work.

This piece of code was borrowed from Michael Pardo. Thank you!

Free 100% online banking account

šŸ’³ Get your free debit Mastercard

No comments yet

Treasure Chest

Get notified of new projects I make
Usually one email every 3 months

Follow me for cool new products and interesting findings on graphic design, web development, marketing, startups, life and humor.


/*Twitter*/ !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); /*Facebook (function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) {return;}js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=28624667607";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));*/ /*Google+*/ window.___gcfg = {lang: 'en-GB'};(function() {var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;po.src = 'https://apis.google.com/js/plusone.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);})();