Help retrieve file from below root directory

I am trying to use this flash button to stream mp3 sound bites.  I wan to store the files below the root directory so that they can not be downloaded.  I wrote the devloper at and his response was this.  Can anyone help me figure out what can be done in CFMX to make this work.

Wimpy Button will not load files below the public root, simply because Flash is not a "server side" type of thing... it is a client side type of thing.

To load files below the public root, you'll have to develop a script that can retrieve the file, then feed the file to the payer.

You can do something like:

"%3F" is a URL encoded "?" -- since you can not have two ? symbols in the query to wimpy.

You script.php will then have to take the request and return the mp3 file.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If that's the case, you can use <cfheader> and <cfcontent> to return the file from a directory below the web root:

Assuming you pass in the file name as a URL variable (I called it 'fileName'), it would look something like this:
<cfset myDirectory = "c:\myMP3s\">
<cfheader name="Content-Disposition" value="inline; filename=#url.fileName#">
<cfcontent type="audio/mpeg" file="#myDirectory##url.fileName#">

Save this and pass the template into the URL as "theFile", and it should work.
jeffmaceAuthor Commented:
This is the code for using the Wimpy Flash Button

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase=",0,47,0" name="wimpy_button01"
 WIDTH="40" HEIGHT="40" id="wimpy_button_1">
      <PARAM NAME=movie VALUE="wimpy_button.swf?theFile=example.mp3">
      <PARAM NAME=quality VALUE=high>
      <PARAM NAME=wmode VALUE=transparent>
      <EMBED src="wimpy_button.swf?theFile=example.mp3" WIDTH="40" HEIGHT="40" quality=high NAME="wimpy_button01"
 TYPE="application/x-shockwave-flash" PLUGINSPAGE=""></EMBED>

I guess the part that I am not understanding is that by using the base code above, the mp3 file plays through the flash button, would this still work the same way?  Or will it open up Windows Media player or some outside player to play the file?  I will be diplaying a table that may have 20-30 sound effects on a page, so there would be 20-30 examples of this flash code.  Would you method still work?

jeffmaceAuthor Commented:
Here is the test code I have so far.   It works fine with the regular HTML Link that I have.. It opens in Windows Media Player which ultimately isn't what I am looking for.  I want to see if it will stream through the flash button unless I am totally getting this wrong.

<table width="600" border="0" cellpadding="0" cellspacing="0">

 <td bgcolor="#CCCCCC"><div align="center" class="style3">MP3 Title</div></td>
 <td bgcolor="#CCCCCC"><div align="center" class="style3">Author Name</div></td>
 <td bgcolor="#CCCCCC"><div align="center" class="style3">Category</div></td>
 <td bgcolor="#CCCCCC"><div align="center" class="style3">Flash Button Test</div></td>
 <td bgcolor="#CCCCCC"><div align="center" class="style3">Test HTML Link</div></td>
<cfoutput query="x">
 <td align="center">
 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 width="40" height="40" id="wimpy_button_#ID#" name="wimpy_button_#ID#">
      <param name=movie value="wimpy_button.swf?theFile=file.cfm&filename=#mp3#">
      <param name=quality value=high>
      <param name=wmode value=transparent>
      <embed src="wimpy_button.swf?theFile=file.cfm&filename=#mp3#" quality=high width="40" height="40" name="wimpy_button_#ID#"
 type="application/x-shockwave-flash" pluginspage=""></embed>
  <td align="center"><a href="file.cfm?filename=#mp3#">Stream Via HTML Link</a></td>
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Without access to the component, I can't tell you for sure how it will respond, but it looks like the solution I proposed is consistent with what the developer suggested, and it will allow you to fetch an MP3 in a non-web-accessible directory.
jeffmaceAuthor Commented:
You can download the demo for Wimpy Button.  Its extremely small.

I got it to work immediately using two files... The first you can call 'servefile.cfm':

<cfset myDirectory = "c:\where i store my files">
<cfset myFile="myFileName.mp3">
<cfheader name="Content-Disposition" value="inline; filename=#myFile#">
<cfcontent type="audio/mpeg" file="#myDirectory##myFile#">

The second will contain the button:

 <!-- Start Wimyp Button Code -->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
flash/,0,47,0" width="35" height="35" name="wimpybutton138" id="wimpybutton138">
   <param name="movie" value="" />
   <param name="loop" value="false" />
   <param name="menu" value="false" />
   <param name="quality" value="high" />
   <param name="bgcolor" value="#FFFFFF" />
   <embed src="" width="35" height="35" bgcolor="#FFFFFF" loop="false" menu="false" quality="high" name="wimpybutton138" id="wimpybutton138" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="" /></object>
<!-- End Wimpy Button Code -->

I'm using FireFox. I didn't test on IE.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jeffmaceAuthor Commented:
But how do you do it with dynamic file names.  If you have 5 songs and each one has a different button becuase its a different mp3.  So you need to have a dynamic tag in there somewhere for it to call the different names
jeffmaceAuthor Commented:
So anyhow, like you said I got it to work in FireFox but not IE.. Can anybody help with why this isn't working in IE?

Here is my
<cfset myDirectory = "E:\Inetpub\www\mp3\">
<cfset myFile="#URL.FileName#">
<cfheader name="Content-Disposition" value="inline; filename=#myFile#">
<cfcontent type="audio/mp3" file="#myDirectory##myFile#">

Here is my flash code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 width="40" height="40" id="wimpy_button_#ID#" name="wimpy_button_#ID#">
      <param name=movie value="wimpy_button.swf?servefile.cfm%3Ffilename=#mp3#">
      <param name=quality value=high>
      <param name=wmode value=transparent>
      <embed src="wimpy_button.swf?theFile=servefile.cfm%3Ffilename=#mp3#" quality=high width="40" height="40" name="wimpy_button_#ID#"
 type="application/x-shockwave-flash" pluginspage=""></embed>
Hope this can help

replace your servefile with follow
<cfset myDirectory = "E:\Inetpub\www\mp3\">
<cfset myFile="#URL.FileName#">
<cfheader name="Content-Disposition" value="filename=#myFile#">
<cfcontent type="#URL.MIME#" file="#myDirectory #myFile#">
also submit your mimetype will be better.
jeffmaceAuthor Commented:
Can you explain why submitting my mimtype will be better when I am only using one type have that already placed in the code?  How does submitting it change anything?  Does IE read this differently than FireFox?  I am only using MP3 files.
then you can just hard code audio/mp3
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.