You need to sign in to do that
Don't have an account?
Ram Chaturvedi
How can we store a picture in a apex variable ?
I am fetching a picture from an object and want to store in a apex variable , in which data type we can store that image and how ?
You can use BLOB datatype.
Best Regards,
Mithun.
it depend how you are fetching the picture, you can store it in a blob variable, or in a string variable and then use EncodingUtil.base64Decode
Good Luck.
and you need to set the value imageObj with the data selected from your object.
now In your VF page put this
<apex:image value="{!imageObj}" />
Regards
and you can show them on VF page as well
i am doing like this
blob img = EncodingUtil.base64Decode(students[0].photo__c);
// error System.StringException: Unrecognized base64 character: <
<apex:image value="{!record.img}"/>
how can i make it correct ?
You can do the below in the class apex
Public student__c studentObj {get;set;}
in the constructor select the student__c record related and set it to studentObj
and in you VF page just put <apex:outputField value="{!studentObj .PhotoUser__c}"/>
And it will work
wrps = new list<wrap>();
wrap w1 = new wrap();
w1.snm = students[0].name ;
w1.fnm = 'The Great Faculty khusuboo';
w1.img = EncodingUtil.base64Decode(students[0].photo__c);
wrps.add(w1);
}
class wrap{
public string snm{set; get;}
public string fnm{set; get;}
public blob img{set; get;}
}
vf code :
<apex:column headerValue="student Photo ">
<apex:image value="{!record.img}"/>
</apex:column>
class wrap
{
public string snm{set; get;}
public string fnm{set; get;}
public Sobject sfdcObject{set; get;}
}
wrps = new list<wrap>();
wrap w1 = new wrap();
w1.snm = students[0].name ;
w1.fnm = 'The Great Faculty khusuboo';
w1.sfdcObject= students[0];
wrps.add(w1);
<apex:column headerValue="student Photo ">
<apex:outputField value="{!record.sfdcObject['photo__c']}"/>
</apex:column>
Good Luck
:-)
and can you give any link where i can study more about "
EncodingUtil.base64Decode
" and if we want to do this by using <apex:image> then how can we do ?