Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Mobile Marketing (https://www.warriorforum.com/mobile-marketing/)
-   -   Download audio from mobile website (https://www.warriorforum.com/mobile-marketing/454810-download-audio-mobile-website.html)

Quentin 20th September 2011 03:38 AM

Download audio from mobile website
 
I have a customer that want to be able to let people download their speech from their mobile website. I added the p3 file which plays fine but it cannot be downloaded.

Anyone know how you can organize a download.

Quentin

Neil B 20th September 2011 04:57 AM

Re: Download audio from mobile website
 
I think if I remember correctly there's an 'app' called Beam Me Up Scotty that lets you download files straight to your smartphone though not sure if it's what you're looking for Q...if it is then you'll need to add a link on the page

Neil B :cool:

Jay Moreno 25th September 2011 09:58 AM

Re: Download audio from mobile website
 
Quote:

Originally Posted by Quentin (Post 4714152)
I have a customer that want to be able to let people download their speech from their mobile website. I added the p3 file which plays fine but it cannot be downloaded.

Anyone know how you can organize a download.

Quentin

Hi Quentin,

<WARNING GEEK TALK>

You have to pass the file name variable over to another file that handles the file type to enable to be register as a downloadable attachement... sounds kinda technical i know - sorry i dont know any other way to explain it... you would create a link/button as follows:

http://www.yourdomain.com/download.php?file=123456

Then the download.php would be something like this:

Code:

<?php
$file = htmlspecialchars($_GET['file']); //get file name from url
$download = "download-".$file.".mp3"; //reconstruct actual filename
include("class/validate.php"); //include validation script
if (Validate::Number($file)){ // Validate file if valid file name continue to download
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
header('Content-Disposition: attachment; filename="'.$download.'"');
readfile("http://www.yourdomain.com/downloads/$download");
}else{ // handle non valid file names ie config.php
echo "Your really want our $file file - Come on don't be silly now!";
}
?>

what your seeing is we are making sure the filename sent from the initial link is a number this prevents someone trying to inject say config.php or configuration.php and which prevents people trying to steal data files with sensitive date

if you see we also don't send the file extension and simply add that during the process - again that prevents someone trying to execute a script too

additionally we have our own validation script that checks and makes sure the variable is a number too... and then tells the script to proceed... you can see in the else statement we handle non numeric variables in a casual manner! lol

what you could do if you want to download a keyword rich domain file name you could simply say do a conditional statement like:

if file = 123456 download this file 80s-disco.mp3

</WARNING GEEK TALK>

if this looks/sounds like a bunch of static white noice lol or you need more info or even to outsource this to us just drop me a PM

cheers,

Jay


All times are GMT -6. The time now is 06:44 PM.