Skip to Content
author's profile photo Former Member
Former Member

Image upload

Hi Experts,

I have a reqiurement that to upload only the jpg,pnf and gif image file. Then I have to pass the url to backend..

can anyone pls explain me with code..

regrds

Kiruba

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2008 at 09:41 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2008 at 10:26 AM

    Hi,

    Search in SDN there are lots of thread and documents on how to upload file and regarding your requirement that you need only .gif and .jpg files to be uploaded then you might be using the following code

    IPrivateUploadView.IContextElement element1 = wdContext.currentContextElement();

    IWDResource resource = element1.getResource();

    if(resource.getResourceType().getFileExtension()==<<with your condition);

    Regards

    Raghu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 21, 2008 at 10:35 AM

    Hi Kiruba,

    go through this doc:[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d0e599cc-2862-2b10-54a9-dcf1376b52d7]

    it will solve ur problem.

    this will upload all kinda image file on server.

    If u get any problem thn lemma knw.

    Regards

    Khushboo

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Raghu,

      As u already reply that, I have to creat the resource for image upload..(jpg,gif,pnf) But Wht I have done was,I have not binded the resource property.suppose when i bind that, the details of my uploaded file has not displayed. Here I have attached my code.

      File ff=new File("New file");

      ff.mkdir();

      try {

      byte[] b=null;

      IWDAttributeInfo att=null;

      IWDModifiableBinaryType bintype=null;

      File f=null;

      FileOutputStream fos=null;

      IWDResource resource=wdContext.currentContextElement().getPhotores();

      if(wdContext.currentContextElement().getResource()!=null){

      b=wdContext.currentContextElement().getResource();

      att=wdContext.getNodeInfo().getAttribute(IPrivateUploadView.IContextElement.RESOURCE);

      bintype=(IWDModifiableBinaryType)att.getModifiableSimpleType();

      wdContext.currentContextElement().setFileExtension(bintype.getMimeType().getFileExtension());

      wdContext.currentContextElement().setFileSize(this.getFileSize(b));

      wdContext.currentContextElement().setDetailsVisiblity(WDVisibility.VISIBLE);

      wdComponentAPI.getMessageManager().reportMessage(IMessagePhUpload.UPLOAD,new Object[]{bintype.getFileName()},false);

      f=new File(""+bintype.getFileName());

      fos=new FileOutputStream(f);

      fos.write(b);

      fos.flush();

      fos.close();

      }

      else{

      wdContext.currentContextElement().setDetailsVisiblity(WDVisibility.NONE);

      wdComponentAPI.getMessageManager().reportContextAttributeMessage(wdContext.currentContextElement(),wdContext.getNodeInfo().getAttribute(IPrivateUploadView.IContextElement.RESOURCE),IMessagePhUpload.NOFILE,new Object[]{""},true);

      }

      } catch (FileNotFoundException e) {

      // TODO Auto-generated catch block

      e.printStackTrace();

      } catch (IOException e) {

      // TODO Auto-generated catch block

      e.printStackTrace();

      }

      where I have to write the code for filtering the images..(jpg,pnf,gif)

      reg

      kiruba

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.