file upload in jsp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anjuman khaleel
    New Member
    • Mar 2012
    • 2

    file upload in jsp

    I have to upload a file using jsp. Am using netbeans 6.9. The file gets uploaded successfully if the source file name & destination file name are same. But in my application I have to change the destination file name for which I used the following code:
    "sourceFileName .renameTo(desti nationFileName) ;"
    But then the function renameTo() is not regonised by the IDE in spite of me importing java.lang.*
    Please help.
    Thanks in advance.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    renameTo is a method in the File class not in the String class.
    Call it on a File handle that represent your file.

    Comment

    • anjuman khaleel
      New Member
      • Mar 2012
      • 2

      #3
      Sorry.. I din't get you..
      I have used it in the try block of my jsp. If i don't rename my source file, it is getting uploaded successfully...

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Don't do sourceFileName. renameTo(destin ationFileName)

        Instead do
        Code:
        new File(sourceFileName).renameTo(destinationFileName);
        if it's allowed on your system.
        P.S You should not be writing Java code in JSPs

        Comment

        Working...