Results 1 to 2 of 2

Thread: file download link

  1. #1

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    file download link

    I want to make sure that when the user clicks a link to a media file it shows the save file dialog

    code:

    Code:
    <%@ Import Namespace="System.IO"%>
    <script language="VB" runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)
     
      Dim root As String = "c:\dirname"
      Dim filepath As String = Request.Params("file")
      Response.Write(filePath)
      If Not filepath Is Nothing Then
    
        If File.Exists(filepath) And filepath.StartsWith(root) Then
          Dim filename As String = Path.GetFileName(filepath)
          Response.Clear()
          Response.ContentType = "application/octet-stream"
          Response.AddHeader("Content-Disposition", _
            "attachment; filename=""" & filename & """")
          Response.Flush()
          Response.WriteFile(filepath)
        End If
      End If
    
    End Sub
    </script>
    but when the user gets the dialog it doesnt tell the user how big the file is.

    How can i get it to show how big the file is?
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  2. #2
    Fanatic Member
    Join Date
    Jul 2001
    Location
    London UK
    Posts
    671
    Response.AddHeader "Content-Length", FileSize

Posting Permissions

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



Click Here to Expand Forum to Full Width