Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to embed WMV with no download option

Status
Not open for further replies.

XgrinderX

Programmer
Mar 27, 2001
225
US
We keep data files in a folder outside the including some audio and video. I have written and ASP page to grab those files and give the user the ability to view or save. However now I need the ability to embed one of these WMV files into a web page BUT not allow the user the ability to download the file.

I tried pointing the embed src parameter to the same url I use for the view/save, but that did not work. Can I just change the ContentType to some sort of stream or something to get this to work? Any ideas?

-Greg
 
XgrinderX, can you post your embed code?

Thanks

Nick
 
Sure!

The embed is simply:
Code:
<embed src="viewer.asp?f=Folder&fn=Movie.wmv" name="MediaPlayer" width=320 height=240></embed>

Then the important code in viewer.asp is:
Code:
baseFolder = "d:\data\"
folderName = Request.QueryString("f")
fileName = Request.QueryString("fn")
set fso = server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(baseFolder & folderName & "\" & fileName) then
   Response.ContentType = "application/x-unknown"
   Response.AddHeader "Content-Disposition", "attachment; filename=" & fileName
   Set adoStream = CreateObject("ADODB.Stream") 
   adoStream.Open() 
   adoStream.Type = 1 
   adoStream.LoadFromFile(baseFolder & fileName)
   do while not adoStream.EOS
      Response.BinaryWrite adoStream.Read(10*1024)
   loop
   adoStream.Close 
   Set adoStream = Nothing
end if
set fso = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top