Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download pdfs 1

Status
Not open for further replies.

sandravega

Programmer
Feb 10, 2004
43
0
0
AR
Hello everybody
I'm trying to put some links into my page to download pdf files.
The goal is to offer 3 or 4 pdfs and let the user download them; the client requirement is that, when the user clicks the link1, the common dialog "open/download" appears to let the user download de pdf_1, and so with the other pdfs.

He wants it with the left mouse button (no right clicks)
If it is imposible to make the common dialog open/download appears, the basic idea is let the user choose where he wants the download, and perform it.

I suppose that is possible with asp, but I don´t know how and I can´t get on my way

suggestions? some scripts?

Thank you everybody

Sandra
 
You can just put a link to the file as you would in html.

Code:
<a href="[URL unfurl="true"]http://www.somedomain.com/myfile1.pdf">Link[/URL] 1</a>
<a href="[URL unfurl="true"]http://www.somedomain.com/myfile2.pdf">Link[/URL] 2</a>
<a href="[URL unfurl="true"]http://www.somedomain.com/myfile3.pdf">Link[/URL] 3</a>

As for keeping suppressing the mouse button it is really common code on the net. Here is one version of it:

Code:
<SCRIPT LANGUAGE="javascript">

function click() {
if (event.button==2) {
alert('Sorry, this function is disabled.')
}
}
document.onMouseDown=click
</SCRIPT>

Let me know if you need more information
 
Thanks Cassidy,
but, that opens the pdf in Acrobat Reader, not downloads it. I want to avoid opening Acrobat Reader.
Using your example, if I want to download, I have to right click and choose "save link destination as..."
That "right-clicking" is what I want to avoid. I want the "save link destination..." behavior just attached to the left click of the mouse.
By the way, I'm not sure I'm explaining myself clearly because I'm not an english speaker... sorry If I don't

Thanks again

Sandra
 
Add this to the top of you code for the files you want to force download:

Code:
response.addheader "content-disposition","attachment; filename='" & Filename & "'" 
server.transfer Filename

Let me know if you need something more.

Cassidy
 
Mmm,
I'm not sure I understand what you mean...
So the page code would be something like

<%
filename="response.addheader "content-disposition","attachment; filename='" & Filename & "'"
server.transfer Filename
%>

<html>
<head>
</head>
<body>
<a href=" 1</a>
</body>
</html>

Or should I wrote an asp function with the asp code you sent and call it from the onclick event of the <a href...> tag?

Sorry for asking too much...

Sandra
 
Hi: Here's the whole enchilada. I'm not sure about the "left-click" issue though. However this will open the dialog box and allow you to open or save.

<%@ Language=VBScript %>

<%

if Request.Form("buttonSubmit") <> "" then

Dim fileName


fileName = "<your file.pdf>"


'ContentType specifies the MIME type of this header.

Response.ContentType = "application/pdf"

'The AddHeader method adds an HTML header with a specified value.
'Content-disposition forces the browser to download.

Response.AddHeader "content-disposition", "attachment; <your file.pdf>"



Response.End

End if

%>

<HTML>
<HEAD>
<TITLE> </TITLE>
</HEAD>

<BODY>
<h4></h4>

<FORM action="<your asp page.asp>" method=POST id=form1 name=form1>
<INPUT type="submit" value="Download Adobe Acrobat document" id=buttonSubmit name=buttonSubmit>
</FORM>

</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top