Forum Stats

  • 3,757,041 Users
  • 2,251,189 Discussions
  • 7,869,700 Comments

Discussions

how to pass the upload file directory on the servlet page from jsp using mutiparts/form-data

3698041
3698041 Member Posts: 7
edited Jan 17, 2019 9:41PM in WebCenter Content

Hi Experts,

Here i have created a connection with UCM using RIDC API in the Servlet class , Now i want a UI from which a user get the file uploaded on the UCM so to achieve that i used JSP page and used the <input type ="file" > as a multiform and on the servlet page it used Apache file upload api to handle the request for the parameter from the following code:

        

  ServletFileUpload sf = new ServletFileUpload(new DiskFileItemFactory());

            List<FileItem> multiparts = sf.parseRequest(request);            

                for(FileItem item : multiparts)                         

                    name = new File(item.getName()).getPath();

                            System.out.println("name fo file "  +name);

like i have uploaded from following folder dir:

d:\test.txt

but the parameter pass on the servlet is "test.txt"

and putting the string "name" put under        dataBinder.addFile("primaryFile", new File("name"));

Then its throw an error here i want to put the full directory of the uploaded doc.

Thanka

Tagged:

Answers

  • Raja Kummathi
    Raja Kummathi Member Posts: 737 Silver Badge
    edited Jan 17, 2019 1:21PM

    Hi ,

    YOu have to pass the full path of your file. I can see you only passing file name and it should not work.

    --Regards

    Raja

  • Srinath Menon-Oracle
    Srinath Menon-Oracle Posts: 6,291 Employee
    edited Jan 17, 2019 9:41PM
    Then its throw an error here i want to put the full directory of the uploaded doc.

    Primary file will only take the file name of the item being passed and it will not take the full path since that is not needed for the wcc primary file attribute.

    So, is the requirement that when a file is being uploaded from a disk folder, that same folder structure should be created on WCC as well ?