Jump to content

PHP File Download


copystart

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.