hello. i inquired elsewhere about how to offer mp3's for downloading by getting php to scan a folder, output the contents of that folder, and offer them for download.
here is a script which will do that just fine. it is a modification of a script offered in a comment at PHP.net: Glob - Manual. since the user comment which offered this script may not be there by the time you read this, i've left that user's comments intact at the top of my variation on the suggested use of the script.
HOWEVER, i'm STILL not satisfied with my own use of this thing-- i want the file to automatically prompt for download when it is clicked, instead of opening in QuckTime (on my system) and attempting to stream the file. i realize that this is an html issue, but i wanted to provide the script below, so i figured i'd ask in hopes that some kind lady or gent might offer his or her solution for an "auto-play" workaround.
before i installed Media Player Classic, Firefox WOULD automatically download when an mp3 was clicked, so...
in short-- how do i workaround the browser media-player plugin so i don't have to tell my users to "right click and 'save as' "? i hate that corny old phrase, and i don't want to be another who clutters my html code with that nonsense-- the user shouldn't have to think so much!
thanks for your help!
enjoy my variation on the PHP glob() function illustration below!!
<?php
/* alpharead version 3: This function returns an array containing the names of the files inside any given folder, excluding files that start with a '.', as well as the filenames listed in the '$killit' array. This array is sorted using the 'natural alphabetical' sorting manner. If no input is given to the function, it lists items in the script's interpreted folder. Version 3 fixes a MAJOR bug in version 2 which corrupted certain arrays with greater than 5 keys and one of the supposedly removed filenames.
written by Admiral at NuclearPixel.com */
function alpharead3($dir){
if(!$dir){$dir = '.';}
foreach(glob("$dir/*") as $item){$sort[]= end(explode('/',$item));}
$killit = array('index.html', 'index.php', 'thumbs.db', 'styles.css');
$killcounter = 0;
foreach($sort as $sorteditem){
foreach($killit as $killcheck){
if(strtolower($sorteditem) == strtolower($killcheck))
{unset($sort[$killcounter]);}
}$killcounter++;}
if($sort){natsort($sort);}
foreach($sort as $item){$return[]= $item;}
if(!$return){return array();}
return $return;
}
//some basic usage - list mp3 files for downloading
$filelist = "
<table>
<tr><th>Filename on Left- Click to Download at Right</th></tr>
<tr><td><ol>";
$folder = 'files/mp3';
foreach(alpharead3($folder) as $item)
{
$filelist .= '<li>'.$item.' - <a href="'.$folder.'/'.$item.'" target=\"_parent\">download</a></li>';
}
$filelist .= "
</ol></td>
</tr>
</table>";
?>