cancel
Showing results for 
Search instead for 
Did you mean: 

Image upload

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Kushboo,

I have created one folder to save my image files in server.. But the images get uploaded outside the folder.. any idea pls..

reg

Kiruba.R

Former Member
0 Kudos

Hi,

Go through the following document on how to create a directory on server and to upload the file on desired location.

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/607e9392-8167-2b10-b9a8-e0aa297e88c6]

Regards

Raghu

Former Member
0 Kudos

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

Former Member
0 Kudos

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

former_member192434
Active Contributor
0 Kudos