ASP file download manager (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


bobby -> ASP file download manager (9/30/2005 12:34:11)

I'm having trouble with this script:

Response.ContentType = "application/asp-unknown"
Response.AddHeader "content-disposition","attachment; filename=" & fileName
Set FStream = Server.CreateObject("ADODB.Stream")
FStream.Open()
FStream.Type = 1
FStream.LoadFromFile(filePath&filename)
Response.BinaryWrite FStream.Read()
FStream.Close
Set FStream = Nothing
Response.End


It works fine with everything except for PDF's

for some reason they get corrupted during the file transfer and Acrobat can't open them. They download just fine if you navigate directly to the file itself...

Thru this script I get the following error in Acrobat:
quote:


Acrobat could not open 'filename.pdf' because it is either not a supported file type or because the file has been corrupted (for example, it was sent as an email attachment and wasn't correctly decoded).


Any ideas?

[8|]




Spooky -> RE: ASP file download manager (9/30/2005 15:19:19)

Open the pdf with notepad and see if theres a vbscipt error?




bobby -> RE: ASP file download manager (9/30/2005 16:01:57)

well who would have thought, LOL

error '800a0bba'

I've found several reasons for this, applied some of the fixes and nothing works yet... I'll keep looking...

Thanks Spooky...

If anybody knows how to fix this quickly it will save me some google time [;)]




Spooky -> RE: ASP file download manager (9/30/2005 16:08:23)

Is that all there is?
What size is the original pdf file ?




bobby -> RE: ASP file download manager (9/30/2005 16:15:53)

33.4 KB

ADODB.Stream
error '800a0bba'
File could not be opened.
/ASTMdownload.asp, line 42


line 42:
FStream.Type = 1


I've found a bunch of threads on this error, but so far nothing that fixes the problem...





bobby -> RE: ASP file download manager (9/30/2005 16:19:37)

I've changed my link to redirect directly to the file itself for now, but I'd rather obfuscate the download directory so that my "authorized" visitors (it's in a password protected zone) won't know where things are to bypass the security checkpoint in the future.

I've tried changing the "1" on line 42 to a "0" and a "2" just for S&G but no joy





Spooky -> RE: ASP file download manager (9/30/2005 16:20:10)

Does it work if you change to "application/pdf" ?

What happens when you write "filePath&filename" then end the script - is the path correct?




bobby -> RE: ASP file download manager (9/30/2005 16:26:53)

anybody know the ADODB type library for PDF?

Ive found six different ones online and none of them seem to work, LOL

[:D]




Spooky -> RE: ASP file download manager (9/30/2005 16:28:38)

??

Response.ContentType = "application/pdf"




bobby -> RE: ASP file download manager (9/30/2005 16:30:46)

quote:

change to "application/pdf"


error '80020005'
Type Mismatch




bobby -> RE: ASP file download manager (9/30/2005 16:32:39)

quote:

Response.ContentType = "application/pdf"

Back to the original error...

it's a vicious cycle... [:o]




Spooky -> RE: ASP file download manager (9/30/2005 16:33:52)

Did you check the file path?
Is the directory browseable?




bobby -> RE: ASP file download manager (9/30/2005 16:36:41)

Yes to both...

I'm gonna go try something else real quick...




Spooky -> RE: ASP file download manager (9/30/2005 16:39:56)

Bobby....put down the gun......We will get through this....




bobby -> RE: ASP file download manager (9/30/2005 16:58:57)

LOL

No, my gun... MINE!

[:D]

I tried moving the folder from /downloads/ASTM/ to simply /ASTM/ and it still didn't work... I can navigate directly to the files and view / download but not via the script.

Works fine for now, but I don't like having the file path visible in the browser...

[8|]




Spooky -> RE: ASP file download manager (9/30/2005 17:10:12)

I havent seen too many issues with pdfs.
Other than file permissions and file sizes, they tend to do the same as any other files.
Whats the complete script?




bobby -> RE: ASP file download manager (9/30/2005 17:16:29)

a form posts the document name to this:
<%
if request.form("file") <> "" then
	 response.redirect "download.asp?f=" & request.form("file") & ".pdf"
else
%>


which works fine. The script on download.asp looks like this:
<@ Language=VBScript %>

<%Response.buffer=True

filePath = "d:\http_root\member\public_html\ASTM\"


If request.cookies("name")("value") < 1 then
	Response.redirect "login.asp"
End If

fileName = request.querystring("f")

Response.ContentType = "application/pdf" 
Response.AddHeader "content-disposition","attachment; filename=" & fileName
Set FStream = Server.CreateObject("ADODB.Stream")
FStream.Open()
FStream.Type = 1
FStream.LoadFromFile(filePath&filename)
Response.BinaryWrite FStream.Read()
FStream.Close
Set FStream = Nothing
Response.End

'////////////////////////////////////////
%>


It has worked fine with other downloads... this is the first time I've specifically tried to grab a PDF with it...

I think I'm gonna go see a movie now... will worry about this next week. If anybody has ideas help is greatly appreciated.

B




bobby -> RE: ASP file download manager (10/4/2005 16:49:14)

still nada...

just to clarify: if this directory didn't have read access I wouldn't be able to pull up the files directly via browser either, correct?





Spooky -> RE: ASP file download manager (10/4/2005 18:29:00)

I believe correct?




bobby -> RE: ASP file download manager (10/4/2005 18:52:26)

dang... I was hoping this was a problem my host could take care of quickly. They assure me the permissions are as I need them, and I am able to pull up these files directly (if I circumvent the script)

Back to the old drawing board...

Ever feel like Wil E Coyote chasing the roadrunner?

[8|]




Spooky -> RE: ASP file download manager (10/4/2005 22:16:30)

If on frontpage - try a different directory. eg /fpdb/ and then mess with the permissions that are available right click / properties




bobby -> RE: ASP file download manager (10/5/2005 2:07:30)

Not on Frontpage, but I did try moving the directory to see if that changed anything (moved it to the root instead of in another directory)

still no joy

I'm confused. Worked perfectly for everything else so far... nada on these PDF's





Spooky -> RE: ASP file download manager (10/5/2005 15:58:42)

Send me one of those files? Ill stick it on one of our sites and see if the same thing occurs?




bobby -> RE: ASP file download manager (10/5/2005 16:02:00)

sent...

thanks!





Spooky -> RE: ASP file download manager (10/5/2005 16:07:47)

Did you get a verification request from my email?




bobby -> RE: ASP file download manager (10/5/2005 16:18:16)

Got it all, thanks Spooky...

that tells me it's a server issue. off to call the host

[;)]




Spooky -> RE: ASP file download manager (10/5/2005 16:19:56)

I take it it worked fine for you then on our server?
Did you want a copy of the download code for comparision?




bobby -> RE: ASP file download manager (10/5/2005 16:25:10)

Yep, worked to open and to download... send me a copy if you don't mind, or post it here. I'll compare and see if I've messed something up somewhere.

[:D]




Spooky -> RE: ASP file download manager (10/5/2005 16:28:49)

The example that I showed you was using the Dev login, it uses a similar download code to you.
Ive sent you a link - check out the download.asp file in that, or perhaps try the whole login to see if that works?




bobby -> RE: ASP file download manager (10/5/2005 16:33:00)

got it, thanks Spooky

I'll let you know how it turns out

[;)]




Page: [1] 2   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125