In my example above, you'd be able to hide the path to the MP3s, and give them whatever name you want... Hope that helps.
Main Topics
Browse All TopicsI'm selling mp3 files as downloads. After the user has made their purchase, they login to the "Admin" page where all of their purchases are listed. The page that lists the resources / corresponding links is protected, but the mp3 itself is not.
Is there a way that I can protect the mp3 file itself. Could I put it in a directory where a Session ID would be necessary in order to access the directory itself. I'm just shooting in the dark, here, but I want to believe that there's some simple yet brilliant tactic I can employ that would limit the download of said file to only those who cleared a login interface or something along those lines.
Ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you are using access the data type is called "OLE Object".
The practical application is you can create a web page to upload the MP3 file into the database - you can even automatically determine the file name and size from the upload and add this information into the database - there are lots of examples of doing this on EE but I can provide code snippets if required.
Once the file is in the database you can show a list of files to vistors by recalling the file names from the database and they can "download" the files. The download page simply recalls the binary data back from the database and sends it to the browser and using the Response.AddHeader command you can tell the browser it is an MP3 file and provide a suggested name for the file download.
As the download page is in ASP and simply calls a record from the database you can of course add additional code to ensure the user is entitled to access the file from the database and as this code is on the same page it is impossible to bypass.
If you need any code snippets to get you started then let me know. You will also an upload component on your server there are several to choose from but I use ABCUpload from http://www.websupergoo.com
R_Harrison
OK, I'm tracking with you in that I recently had to build an upload interface for a client, but I'm still clueless as far as how the "binary" dynamic fits in. Once the file is uploaded to the server with the way I'm doing it now, the actual file is sitting in a directory and the only way that I can reference it is with a URL.
Can you show me an example of how this works? Mind you've I've got the interface to upload a file to the server, but I don't know how else you would download that file without the URL.
OK, I'm almost there.
I'm using this code and it's working perfectly except for the fact that on a Mac, it doesn't give me a download dialogue, rather it simply opens up the file and begins playing it. How do I ensure that I get the download infrastructure happening on a Mac operating system using the below code...
<%
Dim strMP3Filename
Dim oStream, cAction
cAction = "ShowIt"
'First thing to do is decide if we're going to allow access to the file.
' during testing, we'll set the auth to true...
Session("bolUnlimAuth") = True
If Session("bolUnlimAuth") = False Then
'If they're not allowed to get the file, let them know.
Response.Write "<HTML><BODY><H2>Error!</H
Response.End
End If
'This is a DISK path, not a URL
strMP3Filename = "D:\inetpub\bigshinyplanet
'The ADODB.Stream object is used to read the file
Set oStream = server.CreateObject("ADODB
oStream.Type = 1 'adtypeBinary
oStream.Open
oStream.LoadFromFile(strMP
Response.AddHeader "Content-Length", oStream.Size
Response.AddHeader "Expires", "0"
Response.AddHeader "Cache-Control", "must-revalidate, post-check=0, pre-check=0"
Response.AddHeader "Pragma", "public"
'ContentType header lets the browser know what kind of file this is
Response.ContentType="audi
'The content-disposition header controls how the file will be handled in the browser.
'Using the first line below will cause the browser to display a "file download" dialog,
'asking the user whether to open or save the file, whereas using the second line will automatically
'display the PDF in the browser, without showing the dialog:
Select Case cAction
Case "AttachIt"
Response.AddHeader "Content-Disposition", "attachment;filename=mymp3
Case "ShowIt"
Response.AddHeader "Content-Disposition", "inline;filename=mymp3.mp3
End Select
Response.BinaryWrite oStream.Read
oStream.Close
Set oStream = nothing
%>
R_Harrison...
Is this what you were thinking...
Select Case cAction
Case "AttachIt"
Response.AddHeader "Content-Disposition", "attachment;filename=mymp3
Response.ContentType="audi
Case "AttachIt"
Response.AddHeader "Content-Disposition", "inline;filename=mymp3.mp3
Response.ContentType="audi
End Select
I tried that and I'm still getting the same result. PC displays it as a download, but it's now downloading the mp3 file, rather it's downloading the "Download.asp" page, Mac opens up a QuickTime player and begins playing the file. What am I missing?
Business Accounts
Answer for Membership
by: SquareHeadPosted on 2008-01-02 at 21:51:17ID: 20570912
One way would be to create an ASP page that you have behind authentication, then, on that page, use the ADODB stream object to read/write the binary. Here's an example that should get you started...
Select allOpen in new window