Jump to content

Recommended Posts

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

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.

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...

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;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.