Getting the file path from a File browse button

Hi,
I was wondering if there is a way to extract the whole file path (not just the file name) from a file which is selected using a file browse button?
I am trying to save the file path as text in my database (I don't want to upload the file). I have linked the file browse object to a table field in the database. But when entered in the database, all I get is a series of random characters, followed by the file name. I would like to have the complete file path instead.
Tom

Hi thanks
I've placed the java script into the head of the page, but unsure as to how to change the taget url for my submit button from doSubmit('SUBMIT') to doPrepareAndSubmit('SUBMIT'). In fact I don't actually have a submit button, but a save new record (which performs an SQL INSERT into the database using the values contained in the fields on the page) or a update record buttons instead.
I'm sorry but my knowledge of java scripts is not very good either.
How do I do the follwoing?: if your submit button has not any target set its target to url:
javascript: doPrepareAndSubmit('SUBMIT')
Cheers, Tom

Similar Messages

  • 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();

  • 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 folder(directory path only not file path) from local file system

    Hi Firends,
    How to get folder(directory path only not file path) from local file system , whenevr i will click on browse button.
    Please give reply for this one , if anybody knows.
    Thanks,
    Anderson.

    Hi Anderson,
    if you're using flash.filesystem.FileReference - then it is run in black box - except of filename, size and creation data (and few other properties available after some operation succeeded). This is part of security features in Flash runtime (described in header section):
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference .html
    This for example implies that user can download a content to local machine - but that content cannot be loaded back into Flash runtime. For this you would need either Air runtime flash.filesystem.File:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.h tml
    (so you would created Air runtime based application: desktop or mobile but not web, even as standalone project) or you would need one of 3rd party tools that add file access/file information features to standard Flash runtime applications converted to standalone native applications.
    hth,
    kind regards,
    Peter

  • 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

  • How to get physical file path from logical file path

    Hi
    there is a immediate requirement ,
    I have logical file path but I need to get physical file path from it.
    So is there any FM which providesthis functionality.
    Points will be rewarded.
    Thanks

    Can you please share the piece of code ?
    Which File APIs are you using ?
    For java file, you can get complete path by simple method call : getAbsolutePath() on file object.
    Regards,
    Ashwani Kr Sharma

  • To get the absolute path of a file in JSP

    Hi,
    I want to include a HTML page in a jsp.The path of the jsp should not be hot coded.So that i can get the path from the jsp file i am running and then concat the correspondinghtml file name to the absolute path of the jsp file i am running.What can i do to get the absolute path of the jsp file.

    I dont know if there is a way to get the path of the current jsp - but you sure can get the path to your web application using the ServletContext's getRealPath() method and then if you have stored the html (say x.html) in a folder (called, say 'static') immediately under your application root,
    String contextPath = application.getRealPath("/"); //path to your application ctxt
    String htmlFilePath = contextPath.append("/static/x.html");ram.

  • Read to get the last line from a File

    Hi
    I am sending in a clarification , hoping that I get an efficient solution from the group, should somebody have come across this scenario and implemented.
    How to read or get the last line from a text file , which usually have a no of records, without actually reading or looping through all the lines
    I know there is some solution with the RandomAccessFile, but given there can be some encoding issues or so.
    Please let me know if somebody have implemented the same.
    Thanks n advance

    The character encoding could, indeed, be an issue especially with UTF-8. I think what I'd do is to create a byte array with the encoded, expected end of line sequence in it and work on the file in bytes. For example, seek to the last 100 bytes of the file, read those bytes and look for an EOL sequence backwards. If not found read the previous 100, 200, 400 bytes etc. until you do find an end of line. Then seek to after the EOL and read normally. Remember an EOL sequence might cross a boundary.
    UTF-8 would be a problem, especially with a unix format file because you might mistake part of a multi-byte sequence for '\n'. To be reliable on UTF-8 you'd need to go back three characters looking for sequence start markers (has the previous character got the top bit set, or the one before that the first two bits set, or the one before that the top three bits). Or you could just react to an encoding exception and try another position.

  • Getting the current path from which the form is runnig in 9i OAS

    Hi,
    We are using the built in Get_Application_property to get the
    current path in which the form is running. However this does not
    work in 9ioas and it only returns the form name and not the full
    path. Does anyone have any solutions to this problem?
    Thanks in Advance
    Jeet

    Place it in the classpath, then you can use ClassLoader#getResource().

  • 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

  • Not able to get the actual plan from trace file

    Hi all
    I have a Db package and want to get actual execution plan of all the statements in that pakcage it does provides the plan for System's statements but does not displays the plan for Sql statements
    DB version 9.2.0 using the following sequence of insructions
    set timing on
    set serveroutput on
    alter session set events '10046 trace name context forever ,level 12';
    begin
    run_service.collect_data(sysdate);
    end;
    alter session set sql_trace=false;
    exit; ---exit from Sql
    now look at the output
    select distinct obj#,containerobj#,pflags,xpflags,mflags
    from
    sum$, suminline$ where sumobj#=obj# and inline#=:1
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 1 0.00 0.00 1 1 0 0
    total 3 0.00 0.00 1 1 0 0
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: SYS (recursive depth: 2)
    Rows Row Source Operation
    0 SORT UNIQUE
    0 NESTED LOOPS
    0 TABLE ACCESS BY INDEX ROWID SUMINLINE$
    0 INDEX RANGE SCAN I_SUMINLINE$_2 (object id 1614116)
    0 TABLE ACCESS BY INDEX ROWID SUM$
    0 INDEX UNIQUE SCAN I_SUM$_1 (object id 319)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    db file sequential read 1 0.00 0.00
    SELECT SEQ_NUM, S_DATE, S_TIME, CSTATUS, G_SERVICE,
    B_REFERENCE, V_REFERENCE, M_PRIORITY
    FROM GL_HIST
    ORDER BY S_DATE DESC, S_TIME DESC
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.01 0 0 0 0
    Execute 2819 0.37 0.32 0 0 0 0
    Fetch 2819 2.50 20.47 2786 20164 0 2819
    total 5639 2.88 20.81 2786 20164 0 2819
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 15550 (recursive depth: 1)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    db file sequential read 2786 0.05 18.19
    latch free 4 0.04 0.06
    UPDATE G_ORIG SET G_SERVICE = :B1
    WHERE
    SEQ_NUM = :B5 AND S_DATE = :B4 AND S_TIME = :B3 AND
    C_STATUS = :B2 AND NVL(G_SERVICE, '+') <> NVL(:B1, '+')
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.03 0 0 0 0
    Execute 3731 0.74 0.99 261 18712 119 54
    Fetch 0 0.00 0.00 0 0 0 0
    total 3732 0.74 1.02 261 18712 119 54
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 15550 (recursive depth: 1)
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    db file sequential read 261 0.01 0.19
    latch free 9 0.01 0.04
    COMMIT

    Remove the line alter session set sql_trace=false and just exit/disconnect. The explain plain is contained in the STAT lines in the trace file and are only written when the cursor closes. If you turn off tracing before the cursor closes the STAT lines will not get written.

  • Terminal how can i get the picture dimension of a file?

    Is it possible to get the dimension of an picture (120 x 120 px) via terminal command? The information is visible under the finder "getinfo" command for picture files. Can anyone help?

    You can get image pixel size info using the ImageMagick utilities, which is a GNU package available for installation via the fink pacakage manager, then you can use the terminal command:
    identify image.gif
    ImageMagick also has several other useful conversion and image processing utilities.
    http://www.finkproject.org/
    http://www.imagemagick.org/script/index.php
    Good luck.
    P.S. - There may be ways to interact with AppleScript from Terminal to get the Finder info from a file, but I don't know how to do that.

  • How do I get the real path!!!

    I am trying to get the real path:
    http://xxxxx/listusers.do?section=xxx
    But when I am using request. getRequestURI() I get
    listuser.jsp which is the value that listusers.do returns.
    How do I get the real path?????

    hehe
    You can't get the real path from a virtual
    path..that's why you have virtual paths.

  • Issue with Getting the file path from InputFile component

    Hi,
    One of our requirement is like below:
    I am working on ADF 11g (latest release R1) page. User will select the file and when he/she clicks on the Save button we need to store the file path in the database.
    In the database file_path is varchar2(300). We need to store just the file path. I am using InputFile component but filepath is not getting inserted.
    This is really urgent. It would be really appreciate if anyone can guide me on this.
    Thanks
    MC

    Hi Mahesh,
    I have manage to store the file path from the InputFile component in Jdev 11g. I found the file upload script from this forum and manage to alter it so that i could save the file path to the database. But my problem is to retrieve it back to view as a document. Hope this will help you :)
    This is an example of what I have manage to save to my DB :
    (CLOB) //192.168.238.53/c$/Research/Docs/0906160744/EyeCandyLog.txt
    In my form, I save the file path first before I update the other fields. My code is something like this :
    public void uploadFile(ValueChangeEvent valueChangeEvent) {
    // Add event code here...
    InputStream in;
    FileOutputStream out;
    if(tanda == 0){
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    id = rS01Proposal.dptProposalid();
    tanda = tanda + 1;
    System.out.println("tanda"+ tanda);
    } catch (Exception ex) {
    ex.printStackTrace();
    System.out.println("id"+id);
    proposal = id.substring(6);
    System.out.println("proposal"+proposal);
    UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
    String fileUploadLoc = "//192.168.238.53/c$/Research/Docs/"+id+"/";//The place where file will saved
    //create upload directory
    boolean exists = (new File(fileUploadLoc)).exists();
    if (!exists) {
    (new File(fileUploadLoc)).mkdirs();
    if (file != null && file.getLength() > 0) {
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage("File Uploaded " + file.getFilename() +
    " (" + file.getLength() + " bytes)");
    *// extracting the file message to get the path*
    context.addMessage(valueChangeEvent.getComponent().getClientId(context), message);
    columnL = valueChangeEvent.getComponent().getClientId(context);
    column = columnL.substring(9);
    System.out.println(column);
    columnLengkap = "RS01"+column.toUpperCase();
    System.out.println("columnLengkap"+columnLengkap);
    *try {*
    out = new FileOutputStream(fileUploadLoc + "" + file.getFilename());
    in = file.getInputStream();
    *for (int bytes = 0; bytes < file.getLength(); bytes++) {*
    out.write(in.read());
    in.close();
    out.close();
    } catch (IOException e) {
    e.printStackTrace();
    } else {
    String filename = file != null ? file.getFilename() : null;
    String byteLength = file != null ? "" + file.getLength() : "0";
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage(FacesMessage.SEVERITY_WARN, " " + " " +
    filename + " (" + byteLength + " bytes)",
    null);
    context.addMessage(valueChangeEvent.getComponent().getClientId(context),
    message);
    System.out.println(fileUploadLoc+file.getFilename());
    a = fileUploadLoc+file.getFilename();
    b = b + 1;
    if (flagInsert == 0){
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    rS01Proposal.insertDoc(id,proposal,columnLengkap,a);
    flagInsert = flagInsert + 1;
    System.out.println("tanda"+ tanda);
    //session
    ProposalSession.storeCurrentProposalId(id);
    } catch (Exception ex) {
    ex.printStackTrace();
    }else{
    // update proses
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    rS01Proposal.updateDoc(id,proposal,columnLengkap,a);
    flagInsert = flagInsert + 1;
    //session
    ProposalSession.storeCurrentProposalId(id);
    System.out.println("tanda"+ tanda);
    } catch (Exception ex) {
    ex.printStackTrace();
    }

  • 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

  • Use of titles causes excessive CPU usage

    I have been working on a project in PP CC (all latest updates installed) for the past week.  I have had no problems regardless of the increase in size of the project over time.  Yesterday I began adding a few titles.  After I added the titles the app

  • Variable in Text Caption in Html5

    I am trying to display the contents of a variable on a slide so I am using a text caption.  It works fine on my PC, but on the iPad, where it is using Html5, only the initial value of the variable is being displayed. I've tried delaying when the capt

  • EXECUTE_METHOD_BOR - Application method has processed message 'E'; see long

    Hi All,             I am having the following error in the workflow. Actually the WF was working fine and the past few days i am getting this error. EXECUTE_METHOD_BOR - Application method has processed message 'E'; see long text Actually the error o

  • E-mailed files unopenable after updating to 10.4.10

    Since updating to 10.4.10 none of the files I send can be opened by the reciever. This applies to .mov .doc. and .pdf files to name but three. The .mov files I upload to my .mac account play in my .mac web pages, but not when recieved by third partie

  • How to call UME API from ABAP?

    Hello all, I want to call the UME API using ABAP to change portal users from backend system. Is this possible without JAVA development? How? Thanks for your help, Regards, Guido Knapp