Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. filedownloadproblem(ASP)

filedownloadproblem(ASP)

Scheduled Pinned Locked Moved Web Development
csharphtmldatabasesysadminhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rajiv_kadam
    wrote on last edited by
    #1

    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 -->

    T 1 Reply Last reply
    0
    • R rajiv_kadam

      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 -->

      T Offline
      T Offline
      T M Gray
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups