Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
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
 
Old December 1st, 2005, 05:36 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default 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
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old December 1st, 2005, 06:54 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

 
Old December 1st, 2005, 08:17 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old December 1st, 2005, 10:28 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

 
Old December 1st, 2005, 10:31 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old December 1st, 2005, 10:35 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.

 
Old December 1st, 2005, 10:46 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old December 1st, 2005, 10:56 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hehe, lot of typing!!!

Yep use that code to write the file content.

 
Old December 1st, 2005, 12:35 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

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
 
Old April 13th, 2007, 09:07 AM
Registered User
 
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I keep getting "There was an error opening this document. The file is damaged and could no be repaired

Kenneth L Roach





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard Disk Serial Number Asmatullah VB.NET 2002/2003 Basics 1 December 18th, 2007 04:26 PM
Serial Number of the Hard Disk ivanlaw Assembly Language 0 July 15th, 2007 10:15 PM
Hard Disk Serial Number preetha Ajayan C# 2005 3 June 20th, 2007 06:44 PM
Hard disk serial number alexjiju VS.NET 2002/2003 1 February 3rd, 2007 02:50 PM
Hardware hard disk encryption Weldoer1 Forum and Wrox.com Feedback 1 November 2nd, 2005 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.