FileUpload UI element ...

Hi guys,
I have placed FileUpload UI element into a FileUploadView and binded it to context attributes PdfSource (binary type) and PdfName (string type). Also I have placed a button into the view. Folowing code should be executed after selecting some PDF file and clicking on the button:
public void onActionShowFormPressed(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionShowFormPressed(ServerEvent)
     wdThis.wdGetUploadDownloadInteractiveFormCompController().wdGetContext().currentContextElement().setPdfSource(wdContext.currentContextElement().getPdfSource());
     //wdThis.wdFirePlugToFormView();   
     byte[] content = wdContext.currentContextElement().getPdfSource();
                     String name = wdContext.currentContextElement().getPdfName();
The "name" variable contains the real name of uploaded file. It's right. But the "content" variable contains array of zero size.
Do you have any idea why?
Thaks a lot in advance!
Regards
Zbynek

Hi
Try binding the Resource property of File Upload UI element to 'Resource' under Java Native Type. Once the file is browsed using the Browse button, ask user to click a button say Attach where it would upload to the Web Dynpro context by server round trip. So no coding required.
Now you can get the File name and Resource type using:
String file Name = wdContext.currentContextElement().getVa_Resource().getResourceName();
String resType = wdContext.currentContextElement().getVa_Resource().getResourceType();
The data property is bound to an attribute whose value would not denote the data in the file but would be used to store some property of the same file. Say, in case you need to store the name of the file then you can get it from the resource and set it there so that next time if somebody is trying to access the same file, the file name can be retrieved direcly from the attribute bound to data. That is why when you try printing the length of the byte array it would be always zero rather than what you expected.
Regards,
Tushar Sinha

Similar Messages

  • FileUpload UI element -"browse"label is not coming in Hungrian for Hungrian

    Folks,
    We are using FileUpload ui element in our application, our application supports English , Hugrian languages, Problem is here , label on browse button coming in English for hungrian users.
    I believe  no need to add any translation to browse label in .xlf file,
    can any one tell me how to add Hungrian translation to Browse label, how to check standard translations of file upload ui element?
    Thanks & Regards,
    Veera.

    Hi Anup,
    portal User language is already hungray and rest of the labels in page are coming in hungrian as we maintained in -hu.xlf file.but for FileUpload ui element there is no option to map label of  "browse"  button with a message pool attribute.
    Thanks & Regards,
    Veera.

  • Sending an email with attachments in Java using FileUpload UI Element

    Hello Experts,
    I'm using NWDS 7.01 SP6.
    I have an application that has a FileUpload ui element. The elements resource property is bound to a context node of type Resource from the Local Dictionary from uielementsdefinitions.
    The question I have is, how can I take the uploaded file from the context, and attach it to an email using the javax.mail.* api?
    Do I need to store it somewhere first or can it be taken directly from the context attribute? If I need to store it, where do I store it? 
    Any help or suggestions are appreciated.
    Thanks
    MM

    Hello Experts,
    I'm using NWDS 7.01 SP6.
    I have an application that has a FileUpload ui element. The elements resource property is bound to a context node of type Resource from the Local Dictionary from uielementsdefinitions.
    The question I have is, how can I take the uploaded file from the context, and attach it to an email using the javax.mail.* api?
    Do I need to store it somewhere first or can it be taken directly from the context attribute? If I need to store it, where do I store it? 
    Any help or suggestions are appreciated.
    Thanks
    MM

  • Fileupload  UI element in WD ABAP

    Hi ,
    Any one have worked using fileupload UI element in Webdynpro ABAP.
    Regards
    Usha

    Hi usha...
    try this tutorial....
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f5d3c40a-0801-0010-55b7-9e3b01745a40">upload/download file in WD</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/business_packages/a1-8-4/39tutwd_fileupdownload.zip">File upload/download project</a>
    regards,
    Vijay

  • Upload / Save file via FileUpload UI Element under predefined path

    Hi,
    I am pretty new to this topic and need some help.
    I need a Web Dynpro App where I can select a file via FileUpload UI Element and save this file to a predefined path e.g. to a server. I already found [this help|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71?quicklink=index&overridelayout=true] but in this example the file is stored at the SAP Server!
    How can I achieve this? May you give me a sample code?
    I appreciate your help.
    Regards

    Hi Martni, Above answer was incomplete
    try{                         
         File fp = new File(relativePath+ fileName);
         fp.createNewFile();
         FileOutputStream fos = new FileOutputStream(fp);
         BufferedOutputStream bos = new BufferedOutputStream(fos);
         InputStream l_is_FileStream = elAttachmentsElement.getVa_Resource().read(false);
         int l_int_NoOfBytes = l_is_FileStream.available();
         byte[] byteArray = new byte[l_int_NoOfBytes];
         l_is_FileStream.read(byteArray, 0, l_int_NoOfBytes);
         bos.write(byteArray);
         bos.flush();
    catch (Exception e) {
         wdComponentAPI.getMessageManager().reportException("Cannot save the file: "+fileName);
    In the above snippet "relativePath" is the path to the folder in WAS and  "filename" is the name of the file along with its extn Ex. test.doc, or image.jpg
    InputStream l_is_FileStream = elAttachmentsElement.getVa_Resource().read(false)
    The above line of code is the sixth line in the snippet and here "elAttachmentsElement" is the element of the node having "Va_Resource" context attribute, which is bound to FileUpload UI element.
    Regards,
    Vishweshwara P.K.M
    Edited by: Vishweshwara P.K.M on Jun 28, 2010 1:31 PM

  • WebDynpro FileUpload UI Element

    Hi All,
    Iam using a FileUpload UI Element in a View of a WebDynpro project. If i selected a file using the 'browse' button, then you click on any tab in the  View and the file path in the inputfield of the fileupload control disappears.When i come back to the tab which has the Fileupload UI element , the file path is missing. Version :CE 7.1
    Has anyone tried this and faced similar issue?
    I have seen others posts , there is no filename attibute to the FileUpload UI element in CE. Is there any other way out to hold back the file resource path in the UI elements when swtcing between tabs?
    Thanks,
    Uma.

    Hi,
    Its a limitation with the fileupload UI. You can check this in its documentation:
    [http://help.sap.com/saphelp_nw70/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm]
    Well there is a workaround for displaying the file name. You can display the file name using label or textview just beside the fileupload UI.
    There is method called getResourceName() for IWDResource to get the filename.
    Hope this will help you.
    thanks & regards,
    Manoj

  • How to limit file size for FileUpload UI element?

    Hi all,
    I'm using the FileUpload UI element in NW2004s SP20.
    I want to limit the size of the uploaded file.
    The simple option is to load the file to the context, check the size, by using
    InputStream stream = resource.read(false);
    double size = stream.available();
    and report errors if any.
    However, I don't want to store huge files in the context or flie system (even temporarily) nor 'spend' network resources for uploading a file that I won't be use...
    Is there a way to limit the file size by using some property for the fileUpload UI element in the server?
    Is there a way to check the file size before it's uploaded (for example like GMAIL does - checks the file BEFORE the actual upload)
    Regards,
    Omri

    Hi Omri,
    "(but this can be checked AFTER the file was uploaded)" - what do you really mean here? I mean your main query is to restrict the file upload if it crosses certain size-limit. What is the use if you check the size after upload?
    My problem is the network traffic and the CPU load if users are trying to download huge files..., if the upload is restricted for size this download problem will not come .. correct?
    Not sure about the UI element properties has something to restrict the size, and if its really related to Network traffic and CPU utilization, i think you've to check with Basis team to re-sizing the servers to meet this new requirement of upload/download if its not considered before.
    Or the last option i could see is to use KM Upload iView if sizing is done with these considerations.
    Thanks,
    MS

  • Ho to create fileupload ui element dynimically?

    Hi,
    Experts,
    I want to create fileupload ui element dynamically in web dynpro for abap and how to pass parameters.
    please suggest me on that.
    Thanks in advance.
    Shabeer ahmed.

    Hi Shabeer,
    Please let us know your complete requirement.
    Thanks,
    Anand

  • Problem in FileUpload UI element

    Hi All,
           I have done all the operations that are there in this lilnk of FileUpload UI element and I am giving the link also
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f5d3c40a-0801-0010-55b7-9e3b01745a40
    Here, Web Dynpro runtime automatically transports different types of MIME files between the client-side user interface or UI element and the server-side controller context.
      Now I have to take that file from server-side conroller
    context and I have to place that file into my desired server path.
      please help me regarding this issue.
    Thanks All

    Hi,
    When u create FileOutputStream object, u can specify the location where u want to place the file in the server. If the file is already in the server, create a FileInputStream object of that file and copy that file in a new location in the server.
    Regards,
    Piyush.

  • FileUpload UI-Element sap-language

    Hello,
    I use the FileUpload UI-Element in my Webdynpro application.
    When I switch the sap-language from DE to EN the text of the Button does not change from "Durchsuchen" (DE) to "Browse" (EN).
    Does anyone know the problem and has a solution to it?
    Thx in advance
    Silke Ramm

    >
    Silke Ramm wrote:
    > Hello,
    >
    > I use the FileUpload UI-Element in my Webdynpro application.
    > When I switch the sap-language from DE to EN the text of the Button does not change from "Durchsuchen" (DE) to "Browse" (EN).
    >
    > Does anyone know the problem and has a solution to it?
    >
    > Thx in advance
    > Silke Ramm
    This is just a guess, but I know from my BSP days that the Browse button for File Uploads can be a little bit different because it is often provided by the browser itself.  It might be that the text isn't being provided by the backend, but by the browser.  You might try changing your language settings within the browser and see if this changes the button label.

  • What is the maximum File size Limit in FileUpload UI element in Webdynpro JAVA/ABAP??

    I need to upload file with more than 15,000 records, which can exceed more than 1 GB.
    Regards,
    Sakthi

    It's an UI element but apparently only in WDA. I guess SAP hasn't back ported it to WDJ as confirmed by SAP note 1145874. See also SAP note 1303325 regarding limitations of FileUpload control in WDJ. Maybe there is a Java EE solution you could leverage. Another option would be to look into Multiple File Upload of KM or even cFolders.

  • Save Uploded Image in FileUpload UI Element to local server

    Hi Guys,
    I need to do be able to upload an image in my WD application and save the image on a local server (not on SAP MIME, SAP Application Server or anything like that please).  The path of the server I need to save it to looks something like this: *
    haxxyy.wx\Files\Another_File\my_image.gif*.
    I am having trouble doing this.  I manage to upload the Image using the WD UI Element FileUpload.  I understand that the Image is being stored as xstring in the "Data" attribute of this Ui Element, But I do not know what to do with this xstring to save it to the pre-mentioned destination.
    Should I use FTP or something...  Or is there a Function Module you know of.
    Kind regards,
    Christiaan

    Hi,
    When u create FileOutputStream object, u can specify the location where u want to place the file in the server. If the file is already in the server, create a FileInputStream object of that file and copy that file in a new location in the server.
    Regards,
    Piyush.

  • Sample code on Creation of Fileupload UI element in Dialog boxes

    Hi all
    i have a requirement like when i click on the button then i need to generate one dialogbox where i create the UI elements like FileUpload.
    can anybody send the sample code on the same?
    Regards
    Sunil

    Hi,
    Below is the sample procedure to save text to .txt file, where you can get dialog box like Fileupload
    You can simply create a button on click of which you can write the following code and test your application. It will be saved as text file.
    String abc = "what ever you want to save to text file save it in the string format";
    try
    IWDCachedWebResource resource = WDWebResource.getWebResource
    abc.getBytes("UTF-8"), WDWebResourceType.UNKNOWN
    resource.setResourceName("Doke.txt");
    IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(
    resource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal()),
    resource.getResourceName());
    window.show();
    catch(Exception ex)
    wdComponentAPI.getMessageManager().reportException( new WDNonFatalException(ex), false );
    or else go for creating confirmation window.
    Regards
    Raghu

  • Error with FileUpload UI Element

    Hi,
        I am trying to develop an application that using which one can upload a file.When I click on the upload button I get the following error:
        com.sap.tc.webdynpro.services.sal.util.cache.WDResourceNotFoundException: Object could not be found in cache, key is null! at com.sap.tc.webdynpro.services.sal.util.cache.WebResourceCache.getResource(WebResourceCache.java:214) at com.sap.tc.webdynpro.services.sal.util.cache.WebResourceCache.getResource(WebResourceCache.java:236) at com.sap.tc.webdynpro.serverimpl.defaultimpl.datatransport.DataTransportFactory.getOutputMassDatasource(DataTransportFactory.java:112) at com.sap.tc.webdynpro.services.sal.datatransport.core.InternalMassDataTransport.getOutputMassDatasource(InternalMassDataTransport.java:44) at com.sap.tc.webdynpro.progmodel.context.ModifiableBinaryType.parse(ModifiableBinaryType.java:101) at com.sap.tc.webdynpro.clientserver.data.DataContainer.doParse(DataContainer.java:1349) at com.sap.tc.webdynpro.clientserver.data.DataContainer.validatePendingUserInput(DataContainer.java:1259) at com.sap.tc.webdynpro.clientserver.data.DataContainer.validatePendingUserInput(DataContainer.java:600) at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.validate(ClientComponent.java:623) at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.validate(ClientApplication.java:659) at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.transportData(WebDynproMainTask.java:688) at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:625) at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59) at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:249) at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154) at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116) at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385) at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263) at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340) at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318) at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821) at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239) at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92) at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37) at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Please help in resolving this.
    Thnx,
    Pravesh Puria.

    Hi,
        I have declared a component controller context node : File (cardinality 0:n)
        In the init method I create an element and bind that to the node.
        //@@begin wdDoInit()
        IPublicFileUploadDownload_comp.IFileElement ele = wdContext.createFileElement();
        wdContext.nodeFile().bind(ele);
         IWDAttributeInfo attrinfo = wdContext.nodeFile().getNodeInfo().getAttribute(IPublicFileUploadDownload_comp.IFileElement.FILECONTENT); 
                attrinfo.getModifiableSimpleType();
        //@@end
       Then when the upload button is clicked then I call a method of the component controller :
       /@@begin uploadfile()
             IWDAttributeInfo attrinfo = wdContext.nodeFile().getNodeInfo().getAttribute(IPublicFileUploadDownload_comp.IFileElement.FILECONTENT); 
              IWDModifiableBinaryType binarymod =       (IWDModifiableBinaryType)attrinfo.getModifiableSimpleType();
              IPublicFileUploadDownload_comp.IFileElement ele = wdContext.currentFileElement();
              if(ele.getFilecontent() != null)
              //     String mimetype = binarymod.getMimeType().toString();
                   ele.setFileextension(binarymod.getMimeType().getFileExtension());
        //@@end
       On deploying I browse and select a file and then click on the button Upload , then I get that message.
    Message was edited by: Pravesh Puria
            Pravesh Puria

  • How to upload excel fiel with 'FileUpload' UI element ?

    Hi,
       my customer donot want to upload excel in CSV format. And how could i convert excel file into my internal table?
    BR.

    For converting excel file to internal table you can use the fm GUI_DOWNLOAD.
    Also refer to the below post. It may be helpful to you. Thanks.
    [Conversion of internal table into excel file format &put it on app server;

Maybe you are looking for