Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Posts
    38
    Rep Power
    0

    Post full path problem

    how to get full path of any file in jsp?

    example:-upload.html
    <html>
    <head>
    <title>Untitled Document</title>
    </head>

    <body>
    <form method="post" action="upload.jsp">
    <input type="file" name="fileupload">
    <input type="submit" name="submit" value="Upload">
    </form>
    </body>
    </html>

    upload.jsp

    <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
    <%
    String path = request.getParameter("fileupload");
    try{

    File afile =new File(path);

    if(afile.renameTo(new File("C:\\folderB\\" + afile.getName()))){
    System.out.println("File is moved successful!");
    }else{
    System.out.println("File is failed to move!");
    }

    }catch(Exception e){
    e.printStackTrace();
    }

    %>

    path variable return only file.txt not whole path like C:\project\file.txt
    Last edited by mcajavaprogramer; 10-12-2010 at 03:11 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    Because that path is completely meaningless for the server?

    In any case, is that form decalred correctly for a file uplaod?
    I thought you were supposed to set it as mulipart/file-data?

  3. #3
    murali.java is offline Member
    Join Date
    Oct 2010
    Posts
    7
    Rep Power
    0

    Default

    Your want to upload a fille to the server...
    this is not the approach to do..
    Google it .. u will get how to upload the file to the server
    Last edited by murali.java; 10-13-2010 at 07:06 AM.

Similar Threads

  1. problem in file path
    By jperson in forum New To Java
    Replies: 2
    Last Post: 01-15-2010, 12:26 PM
  2. Full Screen Frame Resolution Problem
    By Krooger in forum AWT / Swing
    Replies: 2
    Last Post: 11-25-2009, 12:05 AM
  3. class path problem?
    By rdtindsm in forum New To Java
    Replies: 8
    Last Post: 11-16-2009, 06:09 PM
  4. Path Specification problem
    By uhdam in forum AWT / Swing
    Replies: 7
    Last Post: 05-09-2009, 12:13 PM
  5. problem with PATH
    By creativehacker in forum New To Java
    Replies: 4
    Last Post: 07-11-2007, 03:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •