SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to download multiple files to a certain page effectively

    Hello all,
    I've got a page that needs to downlaod 2 Files from the DB, i wanna know how can i make a page that can download multiple files at a time (until now i used 1 file for each file download...)

    So here's an example of what i need

    Page1.asp
    Code:
    sImage = Recordset("FileID")
    <img src="DownloadPics.asp?FileID=<%=sImage%>" onmouseover="this.src='DownloadPics.asp?FileID2=<%=sImage%>'" onmouseout="this.src='DownloadPics.asp?FileID=<%=sImage%>'" />
    DownloadPics.asp (i want this file to be used to download both files)
    This is what i got currently, which downloads image 1 successful, but wont download image2
    Code ASP:
    connection = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("animals.mdb")
    Set conn = Server.CreateObject("ADODB.Connection")
    Set recordset = Server.CreateObject("ADODB.Recordset")
    conn.Open connection
    ' Getting image number 1
    FileID = Request.QueryString("FileID")
    get1 = "SELECT FileName, ContentType, BinaryData FROM Vids WHERE FileID = " & FileID
    recordset.Open get1, conn, 3, 3
    Response.AddHeader "content-disposition", "inline; filename=" & recordset("FileName")
    Response.AddHeader "content-length", recordset("BinaryData").ActualSize
    Response.ContentType = recordset("ContentType")
    Response.BinaryWrite recordset("BinaryData")
    CallToPets.Close
    ' Now i try to get Image number 2
    FileID2 = Request.QueryString("FileID")
    get2 = "SELECT FileName2, ContentType2, BinaryData2 FROM Vids WHERE FileID = " & FileID2
    recordset.Open get2, conn, 3, 3
    Response.AddHeader "content-disposition", "inline; filename=" & recordset("FileName2")
    Response.AddHeader "content-length", recordset("BinaryData2").ActualSize
    Response.ContentType = recordset("ContentType2")
    Response.BinaryWrite recordset("BinaryData2")
    recordset.close
    conn.Close
    Set recordset = Nothing
    Set conn = Nothing

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just call the download.asp file twice - once for each image. (i.e. download.asp just has the first section of code for image number 1 [plus the close/nothing lines], and in each call FileID contains the ID of the image to be streamed). As far as the web browser is concerned, download.asp is just an image file. So just put the <img src="download.asp"> tags for each image to be displayed.

    Like I said in my PM - you've just got to think through these things logically.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i think i understand what u're saying, but under the same ID there are 2 Photos ( the one that appears intially, and the 2nd which appears when u mouseover the current image) :P

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    solved...;p thanks for the help

    My mistake was when i tried to get image number 2, i used FileID2 = Request.QueryString("FileID")
    It should've been FileID2 = Request.QueryString("FileID2")

    such a small and annoying problems :P


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •