janlux Posted August 28, 2009 Share Posted August 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/172321-question-about-_getid-in-downloadphp/ Share on other sites More sharing options...
lemmin Posted August 28, 2009 Share Posted August 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172321-question-about-_getid-in-downloadphp/#findComment-908594 Share on other sites More sharing options...
janlux Posted August 29, 2009 Author Share Posted August 29, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/172321-question-about-_getid-in-downloadphp/#findComment-908892 Share on other sites More sharing options...
bdmovies Posted August 29, 2009 Share Posted August 29, 2009 Isn't that a preference on the browser? How to save a file? Quote Link to comment https://forums.phpfreaks.com/topic/172321-question-about-_getid-in-downloadphp/#findComment-909047 Share on other sites More sharing options...
cs.punk Posted August 29, 2009 Share Posted August 29, 2009 <?php echo "<a href='songs/{$GET['id']}.mp3'>click here to download</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/172321-question-about-_getid-in-downloadphp/#findComment-909058 Share on other sites More sharing options...
janlux Posted August 30, 2009 Author Share Posted August 30, 2009 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/172321-question-about-_getid-in-downloadphp/#findComment-909323 Share on other sites More sharing options...
janlux Posted August 31, 2009 Author Share Posted August 31, 2009 thank you all finaly I make it! Quote Link to comment https://forums.phpfreaks.com/topic/172321-question-about-_getid-in-downloadphp/#findComment-909892 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.