web_master Posted August 2, 2008 Share Posted August 2, 2008 hi, is there some php sript to download wma file from server. I know that most people know that they can right click on the link and select "Save Target As" but I want to download wma file with a click on link. the link: <a href="http://www.domain.com/folder/1.wma">download</a> dont work in example Firefox... Link to comment https://forums.phpfreaks.com/topic/117817-solved-download-wma-file/ Share on other sites More sharing options...
JasonLewis Posted August 2, 2008 Share Posted August 2, 2008 You could set it up like so... <a href="http://www.domain.com/folder/download.php?file=1.wma">Download</a> Then your download.php page would be setup like so: <?php $file = $_GET['file']; header('Content-Disposition: attachment; filename="directory/{$file}"'); ?> I'm pretty sure that's how it should go. Test it out. Of course to make things more secure, have the files stored in a database and give them hashed ID's. That way it becomes more secure. Link to comment https://forums.phpfreaks.com/topic/117817-solved-download-wma-file/#findComment-605991 Share on other sites More sharing options...
web_master Posted August 2, 2008 Author Share Posted August 2, 2008 You could set it up like so... <a href="http://www.domain.com/folder/download.php?file=1.wma">Download</a> Then your download.php page would be setup like so: <?php $file = $_GET['file']; header('Content-Disposition: attachment; filename="directory/{$file}"'); ?> I'm pretty sure that's how it should go. Test it out. Of course to make things more secure, have the files stored in a database and give them hashed ID's. That way it becomes more secure. Ill try this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <?php $file = $_SERVER['DOCUMENT_ROOT']."/".$_GET['file'].".wma"; if(file_exists($file)){header('Content-Disposition: attachment; filename="'.$file.'"');} ?> </head> <body> <p class="TXT_LINK">· <a href="download.php?file=1" class="TXT_LINK_HREF">download file 1</a></p> </body> </html> but dont work... maybe I do something wrong... Link to comment https://forums.phpfreaks.com/topic/117817-solved-download-wma-file/#findComment-606001 Share on other sites More sharing options...
vikramjeet.singla Posted August 2, 2008 Share Posted August 2, 2008 use only this: NOTE: Don't output anything before header!!!!! <?php $file = $_SERVER['DOCUMENT_ROOT']."/".$_GET['file'].".wma"; if(file_exists($file)){header('Content-Disposition: attachment; filename="'.$file.'"');} ?> Link to comment https://forums.phpfreaks.com/topic/117817-solved-download-wma-file/#findComment-606004 Share on other sites More sharing options...
web_master Posted August 2, 2008 Author Share Posted August 2, 2008 well, the problem is: its download the file, - like 1.wma but the file size is 0, the file size on server is near 15Mb... http://www.internetlabor.net/mkutija/muzicka_kutija/download1.php?file=1 Link to comment https://forums.phpfreaks.com/topic/117817-solved-download-wma-file/#findComment-606011 Share on other sites More sharing options...
web_master Posted August 2, 2008 Author Share Posted August 2, 2008 I f well, the problem is: its download the file, - like 1.wma but the file size is 0, the file size on server is near 15Mb... http://www.internetlabor.net/mkutija/muzicka_kutija/download1.php?file=1 I find the solution!!!!!!!!!!! I find one script on internet which is workin'. As I try in Opera when I downloading the extension will be .htm not the wma as the original file extension... <?php if ($audioformat == "wma") { header('Content-type: audio/x-ms-wma'); } else if ($audioformat == "mp3") { header('Content-type: audio/mpeg'); } $fullpath = $_GET['file'].".wma"; # header info for download header('Content-Length: ' . filesize($fullpath)); header('Content-Disposition: attachment; filename="' . $fullpath. '"'); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Expires: 0'); header('Content-Description: Quran Download'); ob_clean(); flush(); # begin download readfile($fullpath) or die("error!"); exit; ?> Link to comment https://forums.phpfreaks.com/topic/117817-solved-download-wma-file/#findComment-606017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.