Using PHP to Force Download of Audio Files


<?php
$f = $_GET['fileName'];
$m = $_GET['mimeType'];
header(“Content-type: $m”);
header(“Content-disposition: attachment; filename=$f”);
readfile(“$f”);
?>
<?php

$f = $_GET['fileName'];

$m = $_GET['mimeType'];

header("Content-type: $m");

header("Content-disposition: attachment; filename=$f");

readfile("$f");

?>

Use:

http://jameswomack.com/deep-thoughts/a/download.php?fileName=Bubble-Calvalry.ogg&mimeType=application/ogg

 


Custom JavaScript Function to Submit Form Data

function ajaxFunction(formID,resultID)
{
 var xmlhttp;
 if (window.XMLHttpRequest)
 {
 xmlhttp=new XMLHttpRequest();
 }
 else
 {
 // code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 xmlhttp.onreadystatechange=function()
 {
 if(xmlhttp.readyState==4)
 {
 document.getElementById(resultID).innerHTML=xmlhttp.responseText;
 }
 }
 var params = new Array();
 var cleaned = new Array();
 var elems = document.getElementById(formID).elements;
 var j = 0;
 for(var i in elems){
 if(elems[i].name != '' && elems[i].name != undefined && elems[i].name != 'item' && elems[i].name != 'namedItem'){
 cleaned[j] = elems[i];
 j++;
 }
 }
 for(var i in cleaned){
 params += cleaned[i].name+"="+cleaned[i].value+'&';
 }
 xmlhttp.open(document.getElementById(formID).method,document.getElementById(formID).action,true);
 xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 xmlhttp.setRequestHeader("Content-length", params.length);
 xmlhttp.setRequestHeader("Connection", "close");
 xmlhttp.send(params);
}

You pass the function the ID of your form and the ID of the element that you want to hold the response from your server-side script. This script will automatically use the method and action from your opening form tag.


Temecula Website for Tennis Club

Temecula Valley Tennis Website

A custom developed PHP/MySQL/CSS/xHTML/JavaScript/Flash website for Temecula Valley Tennis. Including Testimonials, photo gallery, about page, contact form, slideshow and more. This website has a content management system (CMS) that allows the client to edit their own content.


Funny Politi

I found one of my designs has been hotlinked on a rabidly right-wing forum.

Hotlinked No. 1

Hotlinked No. 1


Link to James Womack’s Resume

James Womack Resume


Revamped Frontline Strategies logo for Dynamic Vision Design Studio

Frontline Strategies & Media LLC Logo


Mini-site for liking/disliking tweets

Coded in PHP/MySQL, this website allows anyone to approve or disapprove of twitter tweets without having to login. To view and rate my tweets, you would go to http://jameswomack.com/tweetworthy/james_womack


Let's give tweets what they deserve

Let's give tweets what they deserve