Skip to Content
avatar image
Former Member

How to read the complete path in file upload UI

Hi,

I want to know how to read the complete path in file upload UI in java web dynpro.

I have created 1 file upload UI and than when i do browse and select some file say small.jpg from my local PC, desktop , its path is coming in file upload UI like E:\small.jpg,

I want to know how to get this path in java webdynpro code.

Also I want to save that JPG image file whichever end user selects from his desktop using file upload UI to portal server in some specific path, how to save this image file in portal server. I have created 1 folder with name IMAGE in portal server and in that i want to save all the images, how to do that ? path of IMAGE folder is /usr/sap/IMAGE

please let me know..

Edited by: User Satyam on May 11, 2011 8:43 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 11, 2011 at 07:01 AM

    Hi Satyam,

    In webdynpro java, first file stores in server location then it reads from server.

    Create a button with upload and write this code OnAction

    Resource is the attribute name in context of type com.sap.ide.webdynpro.uielementdefinitions.Resource, this attribute is for Resource property for Upload UI Element.

    Then in OnAction of button

    InputStream text = null;

    int temp=0;

    try{

    File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());

    }

    String path = file.getAbsolutePath();

    wdComponentAPI.getMessageManager().reportSuccess(path);

    }catch(Exception e){

    e.printStackTrace();

    }

    //@@end

    }

    By default it stores in location E:\usr\sap\CE7\J00\j2ee\cluster\server0\sample.jpg

    Regards,

    Pradeep

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 11, 2011 at 09:25 AM

    Hi,

    you don't need know the path when choosing file.you just need to create a attribute with type com.sap.ide.webdynpro.uielementdefinitions.Resource and bind it to your file upload ui.

    this attribute store the content of your upload file.you must crate another button and action to handle the attribute

    And you may need use ECM to manage your attachments.

    Add comment
    10|10000 characters needed characters exceeded