filedownloadproblem(ASP)
-
i have to download videos from specific location it is downloaded but when i play the video which is downloaded from website is not playing please help me here is my code and my site is www.bigbonenews.net/downloadvideo.asp?id=33 <!--#include file="common.asp"--> <% OpenDataBase conn id=request("id") 'if id="" then response.Write("no news is present") 'sql1="select * from newsvideo" 'set rs=server.createobject("adodb.recordset") 'rs.open sql1,conn,1,1 'while rs.eof<>true sql="select * from newsvideo where newsid=" & id set obj=server.createobject("adodb.recordset") obj.open sql,conn,1,1 if obj.eof<>true then 'response.write(obj("news_titile")) body="http://www.bigbonenews.net/videos/" & obj("videoname") & vbcrlf 'obj.close 'obj.movenext end if Server.ScriptTimeout=600 'OpenDataBase conn 'body="/videos/" & vbcrlf 'response.buffer=true Dim stream Dim contents Dim filename filename=obj("videoname") body="http://www.bigbonenews.net/videos/" & filename response.buffer=true strFileType = lcase(Right(filename, 4)) 'another file code starts here Select Case strFileType Case ".asf" ContentType = "video/x-ms-asf" Case ".avi" ContentType = "video/avi" Case ".doc" ContentType = "application/msword" Case ".zip" ContentType = "application/zip" Case ".xls" ContentType = "application/vnd.ms-excel" Case ".gif" ContentType = "image/gif" Case ".jpg", "jpeg" ContentType = "image/jpeg" Case ".wav" ContentType = "audio/wav" Case ".mp3" ContentType = "audio/mpeg3" Case ".mpg", "mpeg" ContentType = "video/mpeg" Case ".rtf" ContentType = "application/rtf" Case ".htm", "html" ContentType = "text/html" Case ".asp" ContentType = "text/asp" Case Else 'Handle All Other Files ContentType = "application/octet-stream" End Select response.Write(strFileType) 'rs.close 'conn.close Response.AddHeader "Content-disposition","attachment;filename=" & filename response.contenttype=ContentType response.write body response.end %> <form action="downloadvideo.asp" method="post"> <input type="hidden" name="id" value="<%=id%>"> </form> <!--starts Main Body --> <!--startclickprintinclude--> <!--starts Top News Story -->
-
i have to download videos from specific location it is downloaded but when i play the video which is downloaded from website is not playing please help me here is my code and my site is www.bigbonenews.net/downloadvideo.asp?id=33 <!--#include file="common.asp"--> <% OpenDataBase conn id=request("id") 'if id="" then response.Write("no news is present") 'sql1="select * from newsvideo" 'set rs=server.createobject("adodb.recordset") 'rs.open sql1,conn,1,1 'while rs.eof<>true sql="select * from newsvideo where newsid=" & id set obj=server.createobject("adodb.recordset") obj.open sql,conn,1,1 if obj.eof<>true then 'response.write(obj("news_titile")) body="http://www.bigbonenews.net/videos/" & obj("videoname") & vbcrlf 'obj.close 'obj.movenext end if Server.ScriptTimeout=600 'OpenDataBase conn 'body="/videos/" & vbcrlf 'response.buffer=true Dim stream Dim contents Dim filename filename=obj("videoname") body="http://www.bigbonenews.net/videos/" & filename response.buffer=true strFileType = lcase(Right(filename, 4)) 'another file code starts here Select Case strFileType Case ".asf" ContentType = "video/x-ms-asf" Case ".avi" ContentType = "video/avi" Case ".doc" ContentType = "application/msword" Case ".zip" ContentType = "application/zip" Case ".xls" ContentType = "application/vnd.ms-excel" Case ".gif" ContentType = "image/gif" Case ".jpg", "jpeg" ContentType = "image/jpeg" Case ".wav" ContentType = "audio/wav" Case ".mp3" ContentType = "audio/mpeg3" Case ".mpg", "mpeg" ContentType = "video/mpeg" Case ".rtf" ContentType = "application/rtf" Case ".htm", "html" ContentType = "text/html" Case ".asp" ContentType = "text/asp" Case Else 'Handle All Other Files ContentType = "application/octet-stream" End Select response.Write(strFileType) 'rs.close 'conn.close Response.AddHeader "Content-disposition","attachment;filename=" & filename response.contenttype=ContentType response.write body response.end %> <form action="downloadvideo.asp" method="post"> <input type="hidden" name="id" value="<%=id%>"> </form> <!--starts Main Body --> <!--startclickprintinclude--> <!--starts Top News Story -->
First I would suggest getting rid of all commented out code before posting. It makes it much easier for other people to read and understand what is going on in your code. You are setting the content type but then you are doing a response.write of a piece of text that happens to be a URL. So all of the "downloaded" files will just be text files with a URL in them. Since it seems the videos are stored on your web server and not in the database, there is no need to set the content type. Just redirect to the URL of the video itself. The web server will set the content type automatically.
OpenDataBase conn
id=request("id")
sql="select * from newsvideo where newsid=" & id
set obj=server.createobject("adodb.recordset")
obj.open sql,conn,1,1
if obj.eof<>true then
response.redirect "http://www.bigbonenews.net/videos/" & obj("videoname")
else
response.write "Video not found"
end if
obj.close