How to upload a image from local system to rich text field using visualforce page?.i need to upload a image from local system selected image and save to rich text field directly.can anybody help me on this......
2 Answers
If you are binding to a rich text field on an object, you can instead use
<apex:inputField value="{!your.FieldName}"/>
This will give you access to the Salesforce rich text editor, and allow image uploads inline with text.
This may show a image in RichText Field with VF and Apex.
Apex Class :
public class ImagInsertionIntoRichText
{
public String naam{get;set;}
public ID folderid{get;set;}
public Blob file{get;set;}
public void insrt()
{
Document d= new Document();
d.name = naam;
d.body=file; // body field in document object which holds the file.
d.folderid='00l90000000inFEAAY'; //folderid where the document will be stored insert d;
insert d;
}
}
VF Page :
<apex:page controller="ImagInsertionIntoRichText">
<apex:form>
<apex:outputLabel value="Document Name"></apex:outputLabel>
<apex:inputText id="name" value="{!naam}"/>
<apex:outputLabel value="Upload Document"></apex:outputLabel>
<apex:inputfile value="{!file}"></apex:inputfile>
<apex:commandButton value="Save" action="{!insrt}" id="save"/>
</apex:form>
</apex:page>
-
I need to insert a custom object and i need to insert the picture in rich text field– userCommented Jul 19, 2016 at 9:28
-
Can you check this link: ankit-rustagi.blogspot.com/2012/10/… Commented Jul 20, 2016 at 5:13
-
Yes. I refered this link and test my dev org then I post here. @SantanuBoral Commented Jul 20, 2016 at 6:29