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
disturbed118disturbed118 

How to get image on visualforce page saved as an attachment

Hi i have a canvas area where users draw their signatures, but how can i capture this as an attachment when saving?

Pradeep_NavatarPradeep_Navatar

It seems that you are uploading an image on visual force page which is already saved in an attachment. You can use SOQL query in controller on attachement object.

 

Find below a sample code to fetch an image from document object and show on a Visual force page :

 

String strOrgId  = UserInfo.getOrganizationId();

String strDocUrl = '/servlet/servlet.ImageServer?oid=' + strOrgId + '&id=';

String tempUsrPhoto ='';

String Profile_photo.png ;

List<Document> lstDoc = Database.query('SELECT d.Id, d.Name, d.Body, d.ContentType, d.IsPublic, d.FolderId  FROM Document d WHERE d.Name = 'profile-photo');

 

if(lstDocs != null && lstDocs.size() > 0)

      {

      for(Document doc :lstDocs)

      {

                  if(doc.name == 'profile-photo')

                    tempUsrPhoto = strDocUrl + doc.id;  

      }             

      } 

            Profile_photo.png = tempUsrPhoto;         

 

Hope this helps.

bcgbcg

Hi there,

Will you please send me the code for visualforce page.

Thanks in advance...

Regards

communitycommunity

What are we returning from the method?  VF code, please