Click to See Complete Forum and Search --> : download page


orionbrock32
08-04-2006, 04:06 PM
Any suggestions on creating a page to download pdfs. I am creating a page where users can view a list of pdfs then download the one they want.

the big issue is reading the files that are in the directory as we will be scanning the files directly to the folder.

any suggestions would be helpful.

ejrhodes
08-04-2006, 10:14 PM
Look into ADODB.Stream. We are doing something similar where we pass the file id into an asp page, and using the adodb to load the file into the stream and stream the file down to the user.

vanny
08-05-2006, 01:46 AM
IF all the pdf's are in one directory use the File System Object to retreive all the files in the folder and write them to the screen.

As long as they site in a directory that IIS can see, you can just us an A HREF tag for the end user to download them


Something like this will help


sDepth = "/pdf/"

set oFSO = Server.CreateObject("Scripting.FileSystemObject")
set oFolder = oFSO.GetFolder(server.MapPath(sDepth))

FOR each oFile in oFolder.Files
Response.write oFile.name & "<BR>"
NEXT

set oFSO = nothing
set oFolder = nothing

ejrhodes
08-05-2006, 10:39 AM
Vanny's method will work but it must be in a directory IIS can see, and it also will allow your users to guess the filenames of other files in the directory that you may not want them to see. It depends on your requirements

orionbrock32
08-07-2006, 10:13 AM
Vanny,

When i try your method i am getting a

Microsoft VBScript runtime error '800a004c'

Path not found

/scanned_documents.asp, line 11

error

sDepth = "/pdf/"

set oFSO = Server.CreateObject("Scripting.FileSystemObject")
set oFolder = oFSO.GetFolder(server.MapPath(sDepth))

FOR each oFile in oFolder.Files
Response.write oFile.name & "<BR>"
NEXT

set oFSO = nothing
set oFolder = nothing


line 11 is - set oFolder = oFSO.GetFolder(server.MapPath(sDepth))

Is there something i need to change on there?

ejrhodes
08-07-2006, 10:45 AM
Its saying it can not find the path to that folder. Does that folder reside on your file system?

orionbrock32
08-07-2006, 11:49 AM
they are in the general folder, do i need to create a folder for them?

ejrhodes
08-07-2006, 11:53 AM
MapPath is looking for a folder called /pdf/. You need to tell that command the name of the folder where the files are. I would recommend creating a folder on your file system just for the files you want to be downloaded.

orionbrock32
08-07-2006, 12:27 PM
that did it, thanks. works great.

we are using this for only one customer so there will not be a security issue with them seeing something they shouldn't.