Kilitli Automatically open a local file from a web page

  • 11 Nisan 2012 Çarşamba 20:23
     
     

    Hi all,

    I would like to design a web service ( or a script embedded into a web page running on a local host) which accepts fileid as a parameter and then automatically open corresponding file in the same host.

    for example if we enter http://localhost/openFile.aspx?id="JohnBrown" to browser on a windows PC, it should automatically open file JohnBrown.ppsx stored in the hard drive.

    Could you guide me how to achieve this?

    Thanks


    • Düzenleyen Uw-RfidLab 11 Nisan 2012 Çarşamba 21:07
    •  

Tüm Yanıtlar

  • 12 Nisan 2012 Perşembe 11:46
     
     

    Create the following pages to open file -

    Page One = page with link to page two

    <%@LANGUAGE="VBSCRIPT"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <a href="download_go.asp">Download File</a>
    </body>
    </html>

    Page Two = page with code to get file

    <%@LANGUAGE="VBSCRIPT"%>
    <%
    Dim objStream, myContents, myFileName

    myFileName = "<Get the filename from querystring & add file extension>"

    Response.ContentType = "application/octet-stream"
    Response.AddHeader "content-disposition", "attachment; filename=" & myFileName

    Set objStream = Server.CreateObject("ADODB.Stream")

    objStream.Open
    objStream.LoadFromFile Server.MapPath(myFileName)
    myContents = objStream.ReadText

    Response.BinaryWrite myContents

    objStream.Close
    Set objStream = Nothing
    %>


    Thanks, AT

  • 14 Nisan 2012 Cumartesi 17:03
    Moderatör
     
     
    Which hard drive? The server hard drive or the client hard drive?

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

  • 16 Nisan 2012 Pazartesi 08:24
     
     

    Hello,

    Please clarify that where the file is located on server or client machine? I dont think there is some way by which we can open a file located on client machine.

  • 17 Nisan 2012 Salı 14:36
     
     

    This is against Security best practices and I am sure no browser will allow you to open a local file unless until security is negotiated.

    You have three options.

    Option One

    Use Active X and prompt user to download and install your active X and from Active X you can open a file.

    Option Two

    HTML 5 allows you to do this task up to some extent.

    Option Three

    Ask user to upload the file to server and using a powerpoint viwer control from serverside you can show the requered ppt

    Your question has nothing to do with asmx web service and we have a more dedicated forum for asp.net @ http://forums.asp.net/ where some expert can give you prompt answer.


    Lingaraj Mishra

  • 19 Nisan 2012 Perşembe 12:10
     
     
    Client harddrive
  • 19 Nisan 2012 Perşembe 12:21
     
     

    We have our NFC tag reader application which only opens valid http urls. So we want to redirect request through a web page running on local host. So when we embed URL http://localhost/openFile.aspx?id="JohnBrown" to NFC tag, the reader will open this URL but we want to design openFile.aspx file in a way that it will take id "JohnBrown" and then open a local file defined by URL "file:///C:/JohnBrown.ppsx"