function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Taps makTaps mak 

how to save image in record

Hi,

       I have one application and in that I  have to capture the image through webcam and then have to save that image in he record.How can I do this?Please I need urgent help.

 

thx.

jiah.choudharyjiah.choudhary

@Taps Mak,

 

You can have rich text field type and save image in that.

ImmuImmu

Hi Mak,

   Iam here sending rough code to save image dynamically

 

<apex:inputFile value="{!file}" >

</apex:inputFile>
<apex:image url="/servlet/servlet.FileDownload?file={!FieldId}"  height="100" width="200"/><br/>
<apex:commandButton Value="Upload" action="{!Upload}"/>

 

Controller

 

public PageReference Upload() {
document d=new document();
d.Name=Name;
d.body=file;
d.folderid='00l90000001SuJs'; //folderid where the document will be stored insert d;
insert d;
List<Document> attachedFiles = [select d.Id,d.body,d.Name from Document d order by Id Desc limit 1];// to display last saved image
if( attachedFiles != null && attachedFiles.size() > 0 ) {
con1=false;
FieldId = attachedFiles[0].Id;
}
return null;
}