Jump to content

question about $_GET['$ID'] in download.php


janlux

Recommended Posts

Hi all,

 

At the first, my congratulations for the forum, its seems that is a lot of info here 

 

Here is my question on $_GET['$ID'] im new on this  ...so if some one can help me it will be great! 

 

 

I have a few files (mp3) in my web site, that I want the users download them from download.php from id

 

there are few files in my web site mp3

 

for ejemple to download the file 93856.mp3 and 49673.mp3 depending on url id in download.php Im about what to put...i have something like this...

 

 

<?php

 

$id=$_GET['id_song'];

 

 

$ID = $_GET['id'];

switch ('ID') {

case 1:

$ann = '93856';

$atr = '.mp3';

case 2:

$ann = '49673';

$atr = '.mp3';

$id_song=

?>

 

or is something like this?

 

<?php

$id=$_GET['id_song'];

 

$id_song=93856

$id_song=49673

?>

 

to get download the files the url for this files is ejemple:

 

http://www.mywebsite.com/folder/downloa ... song=93856

 

http://www.mywebsite.com/folder/downloa ... song=49673

 

or this is wrong? cos' I've read some article on this...but its seems is wrong in all....

 

help me please... 

 

 

hugs to all

 

Link to comment
Share on other sites

I'm not entirely sure what you are asking, but a simple way to do what I think you are asking is something like this:

header("Location: songs/" . $_GET['id_song'] . ".mp3");

 

You would change "song/" to whatever folder your mp3s are in. If they are simply in the root folder, you can delete "songs/."

 

I hope that helps.

Link to comment
Share on other sites

Hi lemmin,

 

I was meaning that I need the indirect link. For example, http://www.mysite.com/getaudio.php?id=12345. The script 'getaudio.php' would take the value of $_GET['id'] and create a direct link to the required file.

 

php file :

<?php

//make the filename from the id

$requested_file = $_GET['id']."mp3";

 

//then construct the url of the requested file

$requested_url = "http://www.mysite.com/audio/".$requested_file;

 

//then redirect to the correct location

header("Location: ".$requested_url, FALSE, 302);

?>

But when they go to that URL, the song start to download inmediatly and there is no save as....and I need to ofer the oportunity to save it in the PC...what I need to do about this case?

Link to comment
Share on other sites

hi cs.punk,

 

but that code that you give me i need to put it on a php with html code page...or not? because I only have download.php that redirect 5 files with indirect link like:

 

http://www.mysite.com/sound/music/download.php?id=12345  and so on with 4 files more.

 

So when the user acces to that link, its start to download imnediatly and open with a win player, and I need to have a ''save as'' to save the file in PC. I dont want the streaming.....

 

What I need to put in the code?

 

<?php

 

//make the filename from the id

$requested_file = $_GET['id']."mp3";

 

//then construct the url of the requested file

$requested_url = "http://www.mysite.com/sound/music/".$requested_file;

 

//then redirect to the correct location

header("Location: ".$requested_url, FALSE, 302);

 

?>

 

 

Link to comment
Share on other sites

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.