Jump to content

Recommended Posts

ok, now i want to write a script that lets me create a url that downloads an mp3 file like this:

 

http://djfreaka.com/songs.php?m=killerfx

 

and have that goto this file

 

http://djfreaka.com/music/killerfx.mp3

 

this is what I have so far, could someone help me with the missing part?

 

<?php
$m = $_GET['m'];

  $file = 'music/'.$m.'.mp3';

?>

 

effigy: Retitled the topic.

You say another mod_rewrite, but this really is not considered a mod_rewrite.

 

At any rate, I am really confused on what is being asked here. I guess this might be what you want:

 

<?php
$m=$_GET['m'];
$file='http://djreaka.com/music/'.$m.'.mp3';
header("Location: " . $file);
die();
?>

 

Your other option might include sending out a header that states it's an MP3 file and then print using fread. For more on the header data check out the first contribution located here http://us2.php.net/manual/en/function.fread.php

 

--FrosT

hey that last one i like way better but i want to make it so it has two variables: cat & file.

 

category being the directory (music, video, images)

 

and file being the file name without it's extension. but what i would now like to do is get it where i can make a link like this:

 

http://djfreaka.com/download.php?cat=music&file=killerfx

 

and have it goto

 

http://djfreaka.com/music/killerfx.mp3

 

see i want to get it to amend the filetype extension based on the category.

 

like if the category is music the filetype would be .mp3 and if the filetype was images then it would be .jpg

 

for reference i pasted the code below that you referred to.

 

<?php

// force to download a file
// ex, ( [url=http://localhost/php/download.php?file=C:/Apache]http://localhost/php/download.php?file=C:/Apache[/url] Group/Apache2/hongkong.php )
// hope this can save your time :-)

$file = $_REQUEST['file'];

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 

header("Content-Type: application/force-download");
header( "Content-Disposition: attachment; filename=".basename($file));

header( "Content-Description: File Transfer");
@readfile($file);

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.