Open a file using URL

In my data base I have a field called AgendaDocument. The
values of this field are just the document name (like JulyAgenda)
with no file extension. Most of these are pdf. I want the user to
click a dynamically created link to open the document. Please help
- see code
thanks

From Rockhiker's first post, it looks like the filename is
stored in the database without a file extension. Just to clarify,
do you have the full filename (with file extension) stored in your
database? If not, there are solutions, but I would definitely
recommend adding a field for file type to your application.
If you don't have the file extension of the file, but know it
is one of only a handful of file types, you can use the
fileExists() method to determine the correct filetype:
<cfif FileExists("C:\Some\Directory\#myFile#.pdf")>
<cfset sFullFileName = "#myFile#.pdf">
<cfelseif FileExists("C:\Some\Directory\#myFile#.doc")>
<cfset sFullFileName = "#myFile#.doc">
Otherwise, you could leverage <cfdirectory> to get a
list of all your files in a query format and then compare your
filename against the values in the directory.

Similar Messages

  • How to open a file using OAF

    Hi,
    I want to open a file using OAF. I know the path and file name.
    How can I open it, if file is in UNIX or in windows, where ever.
    Is there any way to do that.
    Thanks in Advance!!

    Hi Ankur,
    I had something link this requirement, that also for a concurrent program output only, but the output was txt file, and make it a zip file and give a dynamic link and open it.
    For that i used the following code, may be it will help.
    String zipout = pageContext.getParameter("ZIPOUT");
    if(zipout!=null && zipout.equals("Y"))
    try
    DataObject sessionDictionary = (DataObject) pageContext.getNamedDataObject("_SessionParameters");
    HttpServletResponse response = (HttpServletResponse) sessionDictionary.selectValue(null, "HttpServletResponse");
    HttpServletRequest request = (HttpServletRequest) sessionDictionary.selectValue(null, "HttpServletRequest");
    String requestID = pageContext.getParameter("REQUESTID");
    response.setHeader("Content-Disposition","p; filename=CatExtract"+requestID+".zip");
    response.setContentType("application/x-zip-compressed");
    ZipOutputStream zip = new ZipOutputStream(response.getOutputStream());
    try
    byte[] buffer = new byte[1024];
    int bytesRead;
    //to get the value of output directory
    String fileName = "/o"+requestID+".out";
    Serializable[] parameters = { requestID };
    //Get the output URL for this requests output.
    pageContext.getApplicationModule(webBean).invokeMethod("getOutputURL", parameters);
    String outputURL = (String)pageContext.getTransactionValue("OutputURL");
    pageContext.writeDiagnostics(this.getClass().getName(),"outputURL in the xxt CO"+outputURL,1);
    try
    URL fileURL = new URL(outputURL);
    URLConnection urlConn = fileURL.openConnection();
    DataInputStream out = new DataInputStream(urlConn.getInputStream());
    try
    ZipEntry entry = new ZipEntry(fileName);
    zip.putNextEntry(entry);
    while ((bytesRead = out.read(buffer)) != -1)
    zip.write(buffer, 0, bytesRead);
    zip.closeEntry();
    pageContext.writeDiagnostics(entry.getName(), " added.",1);
    catch (Exception ex)
    pageContext.writeDiagnostics(this.getClass().getName(),"Exception 113"+ex,1);
    finally
    out.close();
    catch (IOException ex)
    pageContext.writeDiagnostics(this.getClass().getName(),"Exception 124"+ex,1);
    System.out.println("Exception 124 "+ex);
    Thanks.
    With Regards,
    Kali.

  • Can i open a file using applet?

    Hi,
    I try to open a file using applet.. but an error said "access denied(java.io.FilePermission tempecg.out, read) ...."
    tempecg.out is the file that I want to read.. below is part of my code.. what should I do...?
    currently the file is in my harddisk, next time will be linked using URL, will this be another problem?
    thanks!
    public void run()
    while (true)
    try
    LineNumberReader lr = new LineNumberReader(new FileReader("tempecg.out"));
    while (dv.size() < 240)
    int p = Integer.parseInt(lr.readLine().toString());
    //int p = (int)(Math.random() * 260);
    dv.add(new Point(0,p-130));
    Thread.sleep(2000);
    } catch (InterruptedException e) {}
    catch (IOException e) {}

    Hi pjustin1,
    you must use the policytool.exe given with JDK 1.2.x (or more).
    and with this tool you must add a permission on file (FilePermission) you want to access.
    Christophe.

  • Problem with Photoshop CS6. If I open a file using Camera RAW

    I have a new problem with Photoshop CS6.  If I open a file using Camera RAW, and process it as usual, CS6 doesn't want to save it the way it used to.  I don't know if I changed something by accident or not. 
    Here's what happens now: After opening from ACR to CS6 and completinhg all of my work, I choose "Save as..."  The save as window opens showing the file name and format.  The default format seems to be .PSD.  I use the drop down to select .jpg.  The file saves normally as a .jpg.  When I go to close the image from, I get a new prompt asking, "Save changes to Adobe Photoshop document DSC_xxxx.NEF before closing?
    I looked up at the file name in the bar above the work space and noticed that it does NOT change from "DSC_xxxx.NEF" to "DSC_xxxx.jpg" after I have saved the file as a .jpg,in my webesite  but it always used to do that.  This adds a few extra steps when closing a document and it really slows me down.
    In fact, I wouldn't swear to this, but I think it used to save to .jpg by default, without me specifying this.
    I don't see a setting in the preferences for what to use as the default file format for saving, so I don't know where to change it back.
    Any ideas?
    Thanks in advance

    You are in the wrong forum;  You actually need Photoshop forum at this link:
    <http://forums.adobe.com/community/photoshop?view=discussions>
    Hope you can repost your question at the correct link.

  • Sorry, we couldn't open your file using this feature. Visio Web Access is not available on this site.

    Recently installed Service Pack 1 in SharePoint Server 2013 Farm, post upgrade we are experiencing issue when opening visio documents:
    I am trying to open .vsdx (visio 2013) file but encounter following issue:
    Sorry, we couldn't open your file using this feature. Visio Web Access is not available on this site.
    Under Document library-->Library settings-->Advanced Settings
    Still I cant open file in browser as we always used to. Unfortunately we don't have Visio services in Farm.
    can you share your experiences regarding this issue post Sp1 SharePoint Server 2013.
    Thank You

    Hi Octopus,
    Based on the error message, it seems that the Visio Graphics Service is not started or the Enterprise feature is not enabled.
    I recommend to check the things below:
    Go to Central Administration > System Settings > Manage service on server > check if the Visio Graphics Service is started > then click Application Management > Manage service applications > check if the Visio Graphics Service application
    is created.
    Go to the root site settings page of the site where you got this error, click Site collection features to check if the SharePoint Server Enterprise Site Collection Features is enabled.
    Go to the site settings page of the site where you got this error, click Manage site feature to check if the SharePoint Server Enterprise Site Features is enabled.
    More information about the Visio Graphics Service:
    http://tutorial.programming4.us/windows_server/microsoft-sharepoint-2013---looking-at-visio-services-(part-3)---visio-graphics-service-service-application.aspx
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • I am trying to delete pages from a PDF file. I opened the bookmarks, selected the pages to delete and choose Edit Delete. The selected pages are not deleted. Note: I have to open the file using a passport provided by an external party.

    I am trying to delete pages from a PDF file. I opened the bookmarks in the PDF file, selected the pages to delete and choose Edit > Delete. The selected pages are not deleted. Note: I have to open the file using a passport provided by an external party.

    Resolved

  • Can I open raw files using photoshop elements

    Can I open raw files using photoshop elements

    Yes, depending on the Camera Model and version of PSE.
    All camera makers like to make slight changes to the RAW format for their new models. Adobe then take a few months to produce a camera RAW plug-in to process the new format.
    Give you PSE version and camera model and we could be more help.
    Brian

  • Open pdf file using ms access visual basic 2000 (9.0.2720)

    I'm using Acrobat reader to open pdf file using a vb proceedure , how ever I can't get it to open a specific file thats in another file folder.
    The code I'm using looks like the following: This is windows 7, using the (x86) virtual in 32 bit mode.
    Private Sub Form_Click()
    'checks for valid msds document
    Dim fs As FileSearch
    Dim stAppName As String
    Dim i As Integer
    On Error GoTo Err_form_Click
    Set fs = Application.FileSearch
    With fs
                 .NewSearch
                .LookIn = "c:\program files (x86)\cvmm\msds\"
                .FileName = Me![MSDS Index #] & ".pdf"
                .MatchTextExactly = True
    If .Execute() <> 0 Then
                        stAppName = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe c:\program files(x86)\cvmm\msds\" & Me![MSDS Index #] & ".pdf"
                          Call Shell(stAppName, 1)
               End If
                     End With
    exit sub
    Err_form_Click:
        MsgBox Err.Description
             Resume Exit_form_Click
    Exit_form_Click:
            MsgBox " no file found."
    End Sub
    This used to work when I was using acrobat 5.0,

    You should have quotes around a filename that has spaces in it. Older versions were more forgiving for some reason.
    Much better anyway is to use ShellExecute, which means you don't have to know or care what PDF reading software is installed and how to run it.

  • Opening a file using Webutil_Host.Host Command

    Dear Gurus
    I'm trying to open a file using following command behind a button on my form:
    Webutil_Host.Host('x:\03\03\39920000023.gif');
    I expected from this command to open the given gif file in default image viewer but it takes no action when I press the push button. So should I try something else???

    try this
    Webutil_host command

  • Opening External Files using SWF

    Hi all,
    Is there a way to open external files using swf? I have gone
    through a number of forums and all seem to tell me to open with a
    window projector. my problem is, I need to embed the swf into a
    html to be viewed online... So I need to do it in swf format.
    Any ideas?

    When you say 'external files' I presume you mean local files
    on the users hard drive.
    If that's true:
    When you say 'open' what do you mean? It could mean to open
    and load a text file/xml file or another swf in flash or it could
    mean to launch a document in its native application e.g. .doc
    launches word etc. Flash projectors can do the first thing, but not
    the second thing. And you need to know the path of the file because
    I don't believe you can retreive it from the filereference browsing
    support. 3rd party tools are necessary to really add a lot of file
    system support to projector applications, and then you can do both
    things mentioned here, without the limitations of flash player
    security which is only slightly reduced with regular projector
    files.
    The filereference class in flash is primarily for
    upload/download support. You can't 'open' local files with it.
    There is, to my current knowledge, no way you can do that with
    flash in a html page directly.
    The only way I can think that it might be possible (untested)
    would be to have a separate local MS Office (or any other host for
    a flash activex that gives filesystem access) with some embedded
    flash in a document that (perhaps) could talk via local connection
    with your html page content and which would in turn talk to its VBA
    host to request local file system activity. I don't know if this
    would work because I've not used localconnection, but perhaps it
    might.

  • How do I force safari to open pdf files using Adobe???

    How do I force safari to open pdf files using Adobe and not in the browser?

    You need Acrobat Reader as a Safari plug in.
    http://get.adobe.com/reader/

  • Open pdf files using AutoVue

    I need to open pdf files using AutoVue in .Net Desktop application(Windows Form ). Is it possible?
    If it is possible please help me to.
    Thanks
    Bimal

    Out of the box no
    Doing it requires a good knowledge of .Net and JAVA (specifically JNI) in order to build a JAVA wrapper for .Net
    I would recommend to google on how you can interact with a java applet inside an IEFRame that is sitting inside a .Net application
    Java.NET : Integration of Java and .NET - CodeProject
    But your are on your own there

  • How to open/read file using Java in Unix?

    Hi Friends,
    Can you please help me out how to open/read file using java in unix os? I have create one text file in "/home/test.txt" in unix environment. How to open the same file & read using java code?
    - Hiren Modi

    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Flash Actionscript to Open a FILE not URL

    Hello everyone,
    I was wondering what the actionscript is to open a file in a
    new window?
    getURL opens a URL I want to open a file, not a URL, I cannot
    get it to work no matter what I do. Someone please help me.
    Anything at all would be greatly appreciated.
    Also, I need this script to be done in javascript.......
    Thanks
    Doug

    i think the user "system" is used to connect to the shared folder on the other system.
    this will not work.
    you may configure the OracleAScontrol-Service to logon with an user-account exists on both machines.

  • Two different methods for downloading a file using URL...

    I was just wondering if someone could shed some light on whether I should be downloading files using java.net.URL or java.net.URLConnection
    Here are two ways that I have found to work (and yes I realize that one is outputting to a stream and the other is getting put into a StringBuffer):
          InputStream in = url.openStream();
          byte[] b = new byte[buffSize];
          fileOutStream = new FileOutputStream(fileToBeCreated);
          while ((bytesRead = in.read(b)) != -1){
            totalFileSize+=bytesRead;
            fileOutStream.write(b, 0, bytesRead);
          }and
          URLConnection _con = url.openConnection();
          in = new BufferedReader(new InputStreamReader(_con.getInputStream()));
          String inputLine;
          while ((inputLine = in.readLine()) != null){
              webPageStringBuff.append(inputLine+"\r\n");
          }In both of the above cases url is just a URL object that has already been instantiated with a valid URL.
    So, just to re-iterate, I realize that the output portion of this code is doing something different (i.e. writing to a stream as opposed to appending to a StringBuffer) but I would like to know whether there is any reason to choose using the URLConnection to get the stream as opposed to using the URL to get the stream.
    Thanks,
    Tim

    hi,
    try out the following code
    // Program: copyURL.java
    // Author: Anil Hemrajani ([email protected])
    // Purpose: Utility for copying files from the Internet to local disk
    // Example: 1. java copyURL http://www.patriot.net/users/anil/resume/resume.gif
    // 2. java copyURL http://www.ibm.com/index.html abcd.html
    import java.net.*;
    import java.io.*;
    import java.util.Date;
    import java.util.StringTokenizer;
    class copyURL
    public static void main(String args[])
    if (args.length < 1)
    System.err.println
    ("usage: java copyURL URL [LocalFile]");
    System.exit(1);
    try
    URL url = new URL(args[0]);
    System.out.println("Opening connection to " + args[0] + "...");
    URLConnection urlC = url.openConnection();
    // Copy resource to local file, use remote file
    // if no local file name specified
    InputStream is = url.openStream();
    // Print info about resource
    System.out.print("Copying resource (type: " +
    urlC.getContentType());
    Date date=new Date(urlC.getLastModified());
    System.out.println(", modified on: " +
    date.toLocaleString() + ")...");
    System.out.flush();
    FileOutputStream fos=null;
    if (args.length < 2)
    String localFile=null;
    // Get only file name
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
    localFile=st.nextToken();
    fos = new FileOutputStream(localFile);
    else
    fos = new FileOutputStream(args[1]);
    int oneChar, count=0;
    while ((oneChar=is.read()) != -1)
    fos.write(oneChar);
    count++;
    is.close();
    fos.close();
    System.out.println(count + " byte(s) copied");
    catch (MalformedURLException e)
    { System.err.println(e.toString()); }
    catch (IOException e)
    { System.err.println(e.toString()); }
    ok

Maybe you are looking for

  • How do I remove a digital signature from Adobe Acrobat Pro.  I have set it up wrongly.

    I created a digital signature but I wanted to change the signature and it also was not password protected. So I deleted the signature but cannot delete the certificate to set it up again. Mac OS X (Operating System) So I am unable to delete the digit

  • Can't see a server in Finder's Network view

    Hi, In the Network view of the Finder, my G4 (10.4.3) on the LAN can see my eMac (10.4.4), also on the LAN. My PowerBook (10.4.4, wireless) can see the G4, but cannot see the eMac. I can, however, connect to the eMac from the PB by entering the IP ad

  • Calling BPEL WSDL form ESB(Urgent)

    Hi, Firstly I am new to BPEL. This question might be very simple. I need the solution ASAP. Coming to the usecase. I have one service "A" in ESB and other service "B" in BPEL. To make it simple I need to listen a file using a file adapter in service

  • Can no longer get photos off iPhone

    For months, whenever I put my iPhone into its cradle to recharge/sync, if there were any photos in its "Camera Roll," iPhoto automatically launched, identified/connected to the iPhone, indicated how many photos were available, and offered to download

  • JMS Listener configuration problem

    I am installing IDM6.0 and trying to use the password synch feature with Active Directory. Below are my environment details tomcat 5.0.28 on linux Sun Message Queue 3.6 for JMS When I am configuring the JMS Listener adapter I am getting the below err