Jump to content

Recommended Posts

Hello.

 

Im trying to make a simple PHP file which will return a file for download. For example: www.gwa.com/file.php?ilovechicken.mp3 . This would then in turn return that mp3 and the php file would know the directory and full url where to find the mp3 at and so on. I am making this so I can track file download counts, but so files such as mp3's can still be played through Podcast RSS Feed players.

 

Im not exactly sure how to get the argument or file name and how to then force download the file once called apon that link from an mp3 player or even normal web client.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/51422-php-file-download/
Share on other sites

www.gwa.com/file.php?file_name=ilovechicken.mp3

 

<?php

$file=$_GET['file_name'];

// insert whatever data you want into database or into a file based database.
header('/path/to/'.$file);

?>

 

It's crude, but it is the general principle. If you need further help, get some code together and post back.

 

Hope This Helps,

 

Nate

 

 

Link to comment
https://forums.phpfreaks.com/topic/51422-php-file-download/#findComment-253264
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.