How to get the full path of a file

    If the user selects a file through a browse button, Is there a way, I can get the full path of the file. The file can be from his local hard drive as well.. Can someone advise    

To upload multiple files (example is for 3), try something like this.
== Form section ==
There would be three(3) file form fields for the selection of a file/document to upload, which
each being uniquely named.
<div style="clear: both;">
<cfinput type="file" name="upload_01" dir="ltr" lang="en" size="70" xml:lang="en">
</div>
<div style="clear: both;">
<cfinput type="file" name="upload_02" dir="ltr" lang="en" size="70" xml:lang="en">
</div>
<div style="clear: both;">
<cfinput type="file" name="upload_03" dir="ltr" lang="en" size="70" xml:lang="en">
</div>
== Processing section ==
Checks to see if any files / documents were selected for upload. If none were, then
displays an alert indicating as such. If at least one file/document was selected, then
the process would process the upload.
<cfif isdefined('form.upload_01') and trim(form.upload_01) eq "" and
isdefined('form.upload_02') and trim(form.upload_02) eq "" and
isdefined('form.upload_03') and trim(form.upload_03) eq ""
>
    <p>Did not select any files to upload</p>
<cfelse>
    <cfif isdefined('form.upload_01') and trim(form.upload_01) neq "">
        <cffile
            action="upload"
            destination="C:\path\to\upload\files\to"
            filefield="upload_01"
            nameconflict="overwrite"
            accept="
              application/msword
            , application/vnd.openxmlformats-officedocument.wordprocessingml.document
            , application/vnd.ms-excel
            , application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            , application/pdf">
            <cfcookie name="upload_01_doc" value="#cffile.serverfile#">
            <cfcookie name="upload_01_doc_ext" value="#cffile.serverfileext#">
    </cfif>
    <cfif isdefined('form.upload_02') and trim(form.upload_02) neq "">
        <cffile
            action="upload"
            destination="C:\path\to\upload\files\to"
            filefield="upload_02"
            nameconflict="overwrite"
            accept="
              application/msword
            , application/vnd.openxmlformats-officedocument.wordprocessingml.document
            , application/vnd.ms-excel
            , application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            , application/pdf">
            <cfcookie name="upload_02_doc" value="#cffile.serverfile#">
            <cfcookie name="upload_02_doc_ext" value="#cffile.serverfileext#">
    </cfif>
    <cfif isdefined('form.upload_03') and trim(form.upload_03) neq "">
    <cffile
        action="upload"
        destination="C:\path\to\upload\files\to"
        filefield="upload_03"
        nameconflict="overwrite"
        accept="
              application/msword
            , application/vnd.openxmlformats-officedocument.wordprocessingml.document
            , application/vnd.ms-excel
            , application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            , application/pdf">
        <cfcookie name="upload_03_doc" value="#cffile.serverfile#">
        <cfcookie name="upload_03_doc_ext" value="#cffile.serverfileext#">
    </cfif>
    <cflocation url="completed.cfm" addtoken="no">
</cfif>
== Completed section ==
Can confirm to the person what files were actually uploaded, by displaying file name and file extension.
You can you use the file extension information to display a respective icon for the file type.
<cfoutput>
<cfif isdefined('cookie.upload_01_doc')>
01. #cookie.upload_01_doc# - #cookie.upload_01_doc_ext#<br /></cfif>
<cfif isdefined('cookie.upload_02_doc')>
02. #cookie.upload_02_doc# - #cookie.upload_02_doc_ext#<br /></cfif>
<cfif isdefined('cookie.upload_03_doc')>
03. #cookie.upload_03_doc# - #cookie.upload_03_doc_ext#<br /></cfif>
</cfoutput>
Leonard B

Similar Messages

  • How to get the full path instead of just the file name, in �FileChooser� ?

    In the FileChooserDemo example :
    In the statement : log.append("Saving: " + file.getName() + "." + newline);
    �file.getName()� returns the �file name�.
    My question is : How to get the full path instead of just the file name,
    e.g. C:/xdirectory/ydirectory/abc.gif instead of just abc.gif
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class FileChooserDemo extends JFrame {
    static private final String newline = "\n";
    public FileChooserDemo() {
    super("FileChooserDemo");
    //Create the log first, because the action listeners
    //need to refer to it.
    final JTextArea log = new JTextArea(5,20);
    log.setMargin(new Insets(5,5,5,5));
    log.setEditable(false);
    JScrollPane logScrollPane = new JScrollPane(log);
    //Create a file chooser
    final JFileChooser fc = new JFileChooser();
    //Create the open button
    ImageIcon openIcon = new ImageIcon("images/open.gif");
    JButton openButton = new JButton("Open a File...", openIcon);
    openButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int returnVal = fc.showOpenDialog(FileChooserDemo.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    //this is where a real application would open the file.
    log.append("Opening: " + file.getName() + "." + newline);
    } else {
    log.append("Open command cancelled by user." + newline);
    //Create the save button
    ImageIcon saveIcon = new ImageIcon("images/save.gif");
    JButton saveButton = new JButton("Save a File...", saveIcon);
    saveButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int returnVal = fc.showSaveDialog(FileChooserDemo.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    //this is where a real application would save the file.
    log.append("Saving: " + file.getName() + "." + newline);
    } else {
    log.append("Save command cancelled by user." + newline);
    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(openButton);
    buttonPanel.add(saveButton);
    //Explicitly set the focus sequence.
    openButton.setNextFocusableComponent(saveButton);
    saveButton.setNextFocusableComponent(openButton);
    //Add the buttons and the log to the frame
    Container contentPane = getContentPane();
    contentPane.add(buttonPanel, BorderLayout.NORTH);
    contentPane.add(logScrollPane, BorderLayout.CENTER);
    public static void main(String[] args) {
    JFrame frame = new FileChooserDemo();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    frame.pack();
    frame.setVisible(true);

    simply use file.getPath()
    That should do it!Thank you !
    It takes care of the problem !!

  • How to get the absolute path of a file from the local disk given the file n

    how to get the absolute path of a file from the local disk given the file name

    // will look for the file at the current working directory
    // this is wherever you start the Java application (cound be C: and your
    // application is located in C:/myapp, but the working dir is C:/
    File file = new File("README.txt"); 
    if (file != null && file.exists())
        String absolutePath = file.getAbsolutePath();

  • In Mac how to get the Full name of a file Programmatically?

    Hi Friends,
             I am doing one Mac application for displaying the contents of a file. I can able to get some information about the file by using this code below...
      NSDictionary *dict=[fileManager attributesOfItemAtPath:myPath error:nil];
    Now I want to get the some other informations also like Full Name, copyRight, version... So Please suggest me how to get the full name of a file Programmaticallly?

    Your question doesn't make sense.
    First off, if you are going to get the attributes of a file, you need its full name before you can do anything. So that's part one taken care of.
    This function returns a dictionary full of typical file information (type, size, mod dates, etc.) as well as some HFS data (creator code, type code) which, I strongly suspect, are not "pulled out of the file" but rather generated on the spot. (See NSFileManager for the full list of attribute keys.)
    The other items you hoped of retrieving are not part of the regular file system. Sure, a Truetype font has a copyright string and a version, but what about an HTML file? A PNG? A text file you just created?
    There simply are no standard functions to retrieve copyright and version.

  • How to get the full path of the fmx's directory.

    Hi all,
    I will ship my project to a customer. So I must install forms runtime at the customer's machine.
    I put all of the fmx files of my project into a certain directory at the customer's machine, and I create a desktop shortcut of the forms runtime. In the "start in" field of the shortcut property I put the full path of the directory where I put the fmx files. And in the target field of the shortcut property I put after the ifrun60.exe the name of the fmx file which to call first.
    Now , in one of my forms file I want to get the full path of this directory because I must call Ora_Ffi.Load_Library. And the library which I want to load resides on that directory.
    So how to get programatically the directory where the fmx files reside.
    I know that there is the registry entry FORMS60_PATH, but we plan to ship many projects to that customer; so if I use the FORMS60_PATH variable then there will be an error because there will be many directories. And the customer can launch many of the projects at the same time.
    So how to get it.
    Thank you very much indeed.

    If you are using the d2kwutil library, then you can use the win_api_environment.Get_Working_Directory() function.
    If not, I doubt that there is anyway to get it since the get_application_property(current_form) does not return the full path of the form as it used to in prior versions of Oracle forms such as 4.5.

  • How to get the full path of the plug-in on Mac

    I use SDK function "GetPluginFileSpecification" to get the full path of the plug-in .On Windows,I success(for example I get "C:\Adobe\plugin.aip"), On Mac , I only get the plug-in's name(for example"plugin.aip").If I want to get the full path of the plug-in on Mac,is there other function I can use ?

    Thank you for the answer.
    Unfortunately i'm working on Photoshop plugin, not illustrator.
    i was looking for solution on google and i found this post.
    I hope you can help me becouse this plug-in is very simple, it must execute a file in the same directory where the plugin is installed.
    If i execute system("./Appname.app/Contents/MacOS/AppName"); the plugin search in my home directory (on windows and on MacOS).
    i try to write:
         SPPluginsSuite* sSPPlugins;
        SPPluginRef fPluginRef = message->d.self;
        SPPlatformFileSpecification filespec;
        sSPPlugins->GetPluginFileSpecification(message->d.self, &fileSpec);
        filespec.mReference
        ai::FilePath path(platformFileSpec);
        std::cout << path.GetFullPath().as_Platform() << std::endl;
    but i have several errors.
    Thank you

  • How to get the Real Path of a file which is accessed  by URL?

    iam using tomcat6.0.
    I have a file xyz.xml at the top of the webapplication HFUSE which i can able to access by URL
    http://localhost:8080/HFUSE/xyz.xml
    My problem is how to get the realpath of the file "xyz.xml" for reading and writing purposes.
    I tried various things but i could not able to successfully solved the problem?
    1) File f = new File("/xyz.xml");
    print(f.getAbsolutePath()) ============== it is not fetching the file @ http://localhost:8080/HFUSE/xyz.xml rather it is creating a file
    at the root of the drive where eclipse is running.
    2) File f = new File("xyz.xml");============> this is also not working , it is creating the file xyz.xml in the eclipse directory ..................
    Can anyone please guide on this problem?

    RevertInIslam wrote:
    If you want your context root(i.e HFUSE)
    use this:
    request.getContextPath() //where request is HttpServletRequest object to get the needful path.
    e.g:
    File f = new File(request.getContextPath()+"/xyz.xml");//it will create the file inside HFUSE.
    Hope this helps.
    Regards
    BWrong. The File constructor expects an absolute filesystem path. The HttpServletRequest#getContextPath() doesn't return the absolute filesystem path, it only returns the relative path from the current context root. Use ServletContext#getRealPath() instead, it returns the absolute filesystem path for the given relative path from the current context root.
    File file = new File(servletContext.getRealPath("/"), "xyz.xml");

  • How to get the full path or name of the Layer to which Filter is applied?

    Hi All,
              I have created a layer using some background image as source. How to get the name or ful path of the background image?
    I checked the documentation and found GetPathNameProc(SPPlatformFileSpecification*) function, but I couldn't get the parameter SPPlatformFileSpecification*.
    Is there any other way to get the file path of background layer in my custom filter?
    Thanks,
    Dheeraj

    If this is a client side application then I'd say look into drag-n-drop tutorials.
    i.e. drag file to your application, action listener fires, create File object giving you full name and path of users action.
    If this is a web application then look into the "multipart/form-data" content type specifications on how to upload files.
    i.e. user specifies file from <input type='file' ... /> type, submits, servlet receives data and recreates file locally on application server side.
    If you are thinking that all you need to send a file to a program is the full path and name in a textbox its a little bit more complicated then that.
    Good luck, hope that helps!

  • How to get the full path of a specific programe(flash media live encoder in my case) in air?

    I need to call it in air,but first of all how can I figure out where it's installed programatically?

    If you are using the d2kwutil library, then you can use the win_api_environment.Get_Working_Directory() function.
    If not, I doubt that there is anyway to get it since the get_application_property(current_form) does not return the full path of the form as it used to in prior versions of Oracle forms such as 4.5.

  • How to get the full path name of a file

    Hey everybody, I'm new here and in Java.
    so I will explain my question by giving an example:
    I want to send file from the Desktop by the "Send to" on the popup menu to my program.
    I want to know how can I read the full path name and the file name, and show it on my text box.
    Thanx alot

    If this is a client side application then I'd say look into drag-n-drop tutorials.
    i.e. drag file to your application, action listener fires, create File object giving you full name and path of users action.
    If this is a web application then look into the "multipart/form-data" content type specifications on how to upload files.
    i.e. user specifies file from <input type='file' ... /> type, submits, servlet receives data and recreates file locally on application server side.
    If you are thinking that all you need to send a file to a program is the full path and name in a textbox its a little bit more complicated then that.
    Good luck, hope that helps!

  • Tree control - How to get the full path of selected Item in tree control

    I am Flex newbie. When the user clicks the particular item in
    the tree control I just wanted to get it name along with it's full
    parent.
    Here is my XML
    var dirXML:XML=<root basename="/home/tcegrid">
    <Directories>
    <Dir Name=".autosave" />
    <Dir Name=".emacs.d" />
    <Dir Name="AnsysDistributed">
    <Dir Name="opt"/>
    <Dir Name="root" />
    </Dir>
    <Dir Name="postgres"/>
    <Dir Name="FineTurbo"/>
    <Directories>
    </root>
    The above XML is data provider for Tree control. When the
    user clicks the Dir Name called opt. I wanted it absolute path in
    XML. say Directories.Dir.Dir.@Name is opt
    Can any one tell me how to get this?

    "Thamizhannal" <[email protected]> wrote in
    message
    news:gam9q8$4es$[email protected]..
    >I am Flex newbie. When the user clicks the particular
    item in the tree
    >control
    > I just wanted to get it name along with it's full
    parent.
    > Here is my XML
    > var dirXML:XML=<root basename="/home/tcegrid">
    > <Directories>
    > <Dir Name=".autosave" />
    > <Dir Name=".emacs.d" />
    > <Dir Name="AnsysDistributed">
    > <Dir Name="opt"/>
    > <Dir Name="root" />
    > </Dir>
    > <Dir Name="postgres"/>
    > <Dir Name="FineTurbo"/>
    > <Directories>
    > </root>
    >
    > The above XML is data provider for Tree control. When
    the user clicks the
    > Dir
    > Name called opt. I wanted it absolute path in XML. say
    > Directories.Dir.Dir.@Name is opt
    > Can any one tell me how to get this?
    loop until the parent() property of the XML node is empty.
    HTH;
    Amy

  • How to get the actual path of a file present in the Web content folder

    I have a jasper file which is present inside the Web-Content folder of my project.
    I need to pass this file as an argument to the FileInputStream object. How can i give the actual path of the jasper file, since this project can be deployed anywhere else also.

    You may be able to use the getRealPath or getResource methods in ServletContext

  • How to get the full image directory when i upload the image to web page???

    hai, how to get the full image directory when i upload the image to web page???
    here is the example:
    <form action="uploadfile.jsp" method="post">
    image<input type="file" name="image" />
    <input type="submit" value="submit"/>
    <%
    String s=request.getParameter("image");
    %>
    <%=s%>
    </form>
    i upload the image from C:\image\center.gif. i use request.getParameter just can get the image name like "center.gif". Can anybody help me how to get the full path name. Thanks a lot..

    There is no need to get the path. It is also fairly pointless as the server cannot access the client's local file system.
    Carefully read this article how you can upload files the right way: http://balusc.blogspot.com/2007/11/multipartfilter.html

  • How do I get the full path and filename of the current document?

    I'm writing a format plug-in. How do I obtain the full path and filename of the current image (document) from within my plug-in? Any help would be greatly appreciated!

    I actually just figured this out. For anyone else who would like to know, check out the propetizer sample code in the photoshop sdk. It makes a "filter" plug-in that just spits out all the properties of the document you could ever want to know about. The function I used to get the full path and filename of the current document is PIGetDocumentName(). I hope this helps someone eventually...

  • How to get the pull path name from a file upload window

    Hello everyone!
    I have encountered the following problem with the following JSP code:
    <form method="post" action="filename.jsp">
    Upload JAVA program:
    <input type=file size=20 name="fname" accept="java">
    <input type=submit value="go">
    </form>
    <%
    String s = "";
    if (request.getParameter("fname") != null)
    s = request.getParameter("fname")
    %>
    The value of s is alway the filename. However I want to get the full path in addition to the filename, so that I can read the file. Does anyone know how to get the pull name of the file?
    thanks a lot in advance,

    Dear Sir,
    thanks a lot for your reply. Please let me explain what I intended to do: I want to upload a file from the local machine and then read the content of the file. Therefore I need to the fullpath of the filename like /var/local/file.java instead of file.java. The latter is what I got.
    The problem I have with your code is that the function like "request.getServerScheme()" is not recognized. Maybe is it because I didn't install servelet package? I only installed javax package btw. Also my application runns on Tomcat server if this could give you some information. The error message I had is as follows:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:133: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    url = request.getServerScheme()
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:136: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    + ((("http".equals(request.getServerScheme()) && request.getServerPort() != 80)
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:137: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    ||("https".equals(request.getServerScheme()) && request.getServerPort() != 443))
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:139: cannot resolve symbol
    symbol : method getServletConfig ()
    location: interface javax.servlet.http.HttpServletRequest
    + "/" + request.getServletConfig().getServletName()
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:140: cannot resolve symbol
    symbol : variable path
    location: class org.apache.jsp.addExercise_jsp
    + "/" + path
    ^
    5 errors
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

Maybe you are looking for

  • Can CUBE register with two CUCM clusters?

    We have two CUCM clusters - one is in US and one is in Australia. Currently CUBE is registered with US Cluster with the settings below - sccp local GigabitEthernet0/0 sccp ccm 10.10.1.21 identifier 2 priority 2 version 7.0 sccp ccm 10.10.1.20 identif

  • FCP playback and exporting issue

    Hi, I'm having an issue in FCP where as I'm playing it, all of a sudden a picture will go really wierd - i.e. the colours will be bright blue and pink, and the picture showing will not actually be the correct image, but one from somewhere else in the

  • Planning Error when Importnig Security

    During importing security the following error appears. This key is already associated with an element of this collection Can anyone shed some light on this? Regards

  • Cycle count listing Report not generating out put

    Hi Team , We are into 11.5.10.2 , We have set Auto schedule to weekly in cycle counts and cycle count is not generating output for cycle count listing in Production. But, we are able to generate report output in Test instance and unable to generate i

  • Multiple Channels for Campaigns

    Hi Folks , Is it Possible to possible to Execute a Campaign for Different Communications Channels at Once - If so , how is it possible ? Needed valueable inputs - Thanks in Advance. Regards, Amrita.