SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with reading pdf (ADODB.stream): Please help

    Hi

    I am trying to secure .pdf files by having users login and based on UserID, allow access to certaing .pdf's.
    I have tried it a few different ways using different file types and their corresponding contenttype and nothing happens. I even used the same example from microsoft.com and I get "page cannot be displayed" . Please help:
    BTW, i am using .asp (not asp.net)


    here is my code

    Response.Clear
    Response.ContentType = "application/pdf"
    Const adTypeBinary = 1
    Dim strFilePath
    strFilePath = "test.pdf" 'This is the path to the file on disk.
    Set objStream = Server.CreateObject("ADODB.stream")
    objStream.Open
    objStream.Type = adTypeBinary
    objStream.LoadFromFile strFilePath

    Response.BinaryWrite objStream.Read

    objStream.Close
    Set objStream = Nothing

  2. #2
    SitePoint Zealot yacka's Avatar
    Join Date
    Aug 2006
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried your code and it works for me, provided the file path points to a valid file. Maybe you have a permissions problem?


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
  •