Page 1 of 1

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

Posted: Fri Aug 28, 2009 2:31 pm
by janlux
Hi all,

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

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


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


hugs to all :wink:

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

Posted: Fri Aug 28, 2009 4:06 pm
by cpetercarter
The simple thing is a link which points directly at the file your listeners want to download eg http://www.mysite.com/audio/12345.mp3.

The alternative is some sort of 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. A very simple example might be:

Code: Select all

 
//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);
 

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

Posted: Sat Aug 29, 2009 6:26 am
by janlux
Hello cpetercarter,

Thank you a lot for this !

If I understand and I want the alternative the indirect link, as I have 5 songs the code will be something like this isnt?:
the folder where I have the songs is called audio.


the name of file php : getaudio.php

Code: Select all

<?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);
 
?>
did I need to put the name of the song in the "Location: " ? or the code that you give me is ok and no need to be modificatE?

Because I need that the peopel can save it in theyr PC, any idea on this?

And a lot of thank you!!

Hugs!

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

Posted: Sat Aug 29, 2009 7:19 am
by mrvijayakumar
Hi,

Use downloading script to download the file from web sites. It will be nice for downloading.

viewtopic.php?f=1&t=104572

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

Posted: Sun Aug 30, 2009 1:41 pm
by janlux
Hi mrvijayakumar, thanks for the help, but I didnt undestand it very well.....im newby in php ...

I only want that the people can save the file when they get to the next url:

http://www.mysite.com/getaudio.php?id=12345. with no streaming...only save as and they can save it into their computer....

My code in download is:

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

?>


works very good, but I need only one thing, that permit to ''save as'' the file.......any idea? :(

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

Posted: Sun Aug 30, 2009 3:00 pm
by Ollie Saunders
header('Content-Disposition: attachment') or something like that.

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

Posted: Mon Aug 31, 2009 3:38 pm
by janlux
Ok thank you all :) finally I make it! :)