 |
| HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 1st, 2005, 05:36 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
link to a document on my hard disk out wwwroot
how can i link to a document on my hard disk outwith my Inetpub/wwwroot?
Code:
<iframe src="../../net_contract_pdf/<%=Trim(rs("path"))%>" class="iframe" scrolling="yes" name="content"></iframe>
www.crmpicco.co.uk
|
|

December 1st, 2005, 06:54 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Picco,
You cannot link direct to a file on your hard disk, if you could, any user could surf the contents of your machine to their hearts content.
What are you trying to achieve - document security or something else?
Cheers,
Chris
|
|

December 1st, 2005, 08:17 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i am just trying to view a PDF inside a <IFRAME> i want it to load in the webpage, so does this HAVE to be in the wwwroot?
www.crmpicco.co.uk
|
|

December 1st, 2005, 10:28 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You could binary read & write the file to the page if you don't want to store it one of your web folders...
Code:
Response.ContentType = "application/pdf"
Dim stream
Set stream = Server.CreateObject("ADODB.Stream")
Call stream.Open()
stream.Type = 1
Call stream.LoadFromFile(Server.MapPath("../../myPdf.pdf"))
Call Response.BinaryWrite(stream.Read())
Set stream = Nothing
Response.Flush
Response.End
HTH,
Chris
|
|

December 1st, 2005, 10:31 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks chris, how do i reference the 'read' in the iframe?
Code:
<iframe src="../../net_contract_pdf/<%=airline%>/<%=Trim(rs("filename"))%>.pdf" width="100%"
scrolling="yes" name="contract" id="contract" onload="resize_iframe();"></iframe>
www.crmpicco.co.uk
|
|

December 1st, 2005, 10:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
The page you display in the IFrame will have to do the reading & writing, so you may want to pass a parameter to it that lets you decide which file to write to the page.
|
|

December 1st, 2005, 10:46 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ah, ok. thanks. just noticed this is my 1,000th post! :-)
should the file write out the fil content with this code:
Code:
<%
Response.ContentType = "application/pdf"
Dim stream
Set stream = Server.CreateObject("ADODB.Stream")
Call stream.Open()
stream.Type = 1
Call stream.LoadFromFile(Server.MapPath("../../myPdf.pdf"))
Call Response.BinaryWrite(stream.Read())
Set stream = Nothing
Response.Flush
Response.End
%>
www.crmpicco.co.uk
|
|

December 1st, 2005, 10:56 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hehe, lot of typing!!!
Yep use that code to write the file content.
|
|

December 1st, 2005, 12:35 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
full working script:
Code:
<% ' Last Edit: CRM_01dec05 %>
<%
'''''''''''''''''''''''''''''''''''''''''''''
' file: contractIframe.asp
'''''''''''''''''''''''''''''''''''''''''''''
' load the pdf file from the net_contract_pdf directory
' and insert the content into the IFRAME
'''''''''''''''''''''''''''''''''''''''''''''
airline = Trim(Request.QueryString("airline"))
filename = Trim(Request.QueryString("filename"))
if len(airline) > 2 then
airline = left(airline,2)
end if
Response.ContentType = "application/pdf"
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'... if the specified file exists the load the file from its specified directory
'... and insert it into the IFRAME
If objFSO.FileExists ("../../../../net_contract_pdf/"&airline&"/"&filename&".pdf") Then
Dim stream
Set stream = Server.CreateObject("ADODB.Stream")
Call stream.Open()
stream.Type = 1
Call stream.LoadFromFile(Server.MapPath("../../../../net_contract_pdf/"&airline&"/"&filename&".pdf"))
Call Response.BinaryWrite(stream.Read())
Set stream = Nothing
Else
response.Write "<div align='center'>"
response.Write ""
response.Write "Sorry, the requested Contract could not be found<br>"
response.Write ""
response.Write "</div>"
End If
Response.Flush
Response.End
%>
www.crmpicco.co.uk
|
|

April 13th, 2007, 09:07 AM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I keep getting "There was an error opening this document. The file is damaged and could no be repaired
Kenneth L Roach
|
|
 |