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
Preethi SPreethi S 

upload image

I need to save image in custom object when i click upload button.
Can u tell me?
Ramu_SFDCRamu_SFDC
Review the below posts for this

https://success.salesforce.com/answers?id=90630000000glUkAAI
https://success.salesforce.com/answers?id=90630000000hX8VAAU
Preethi SPreethi S
Thanks Ramu....
I struggled in controller for upload method...
I created  text field for photo...After clicking upload button that the controller save image into this field...can u help me for this?
Preethi SPreethi S
This is my vf code.


<apex:page standardController="BioBr__c" tabStyle="BioBr__c" sidebar="false" extensions="controllerExtension">
<apex:sectionHeader title="Attach File"/>
<apex:form >
<apex:pageBlock title="AttachFile" mode="edit">
<apex:pageBlockSection showHeader="false" columns="1" id="block1">
<apex:outputLabel value="1.Select the file" for="fileName"/>
Type the Path of the file or Click the browse button to find attachment
<apex:inputFile value="Browse" fileName="{!BioBr__c.Photo__c}" id="fileName"/>

<h1>2.Click the "Attach File" button.</h1>
<p>Repeat steps 1 and 2 to attach multiple files </p>
<p>(When the upload is completed the file information will appear below)</p><br/>
<apex:commandButton value="Attach File" action="{!upload}"/>
<br/>
<h1>3.Click the Done button to return to the previous page</h1>
<p>(This will cancel an in-progress upload. )</p><br/>
<apex:commandButton value="Done" action="{!save}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>






Preethi SPreethi S
I created controller below
But it is not working properly...I think i have mistake in upload method...Can u help me for this?


public class controllerExtension{
    public controllerExtension(ApexPages.StandardController controller) {

    }
    public BioBr__c bio{
    get {
  if (bio == null)
       bio = new BioBr__c();
      return bio;
    }
    set;
  }


public PageReference save(){
PageReference acctPage = new ApexPages.StandardController(bio).view();
        acctPage.setRedirect(true);
        return acctPage;
}
public PageReference upload(){


  try { 
system.debug('++++++++' +bio);
       insert bio; 

    } catch (DMLException e) { 
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file')); 

      return null; 

    }
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully')); 

    return null; 
}


}


kevin Carotherskevin Carothers

Hi Preethi,

Have you looked at this post?

https://developer.salesforce.com/blogs/labs/2010/07/how-to-update-picture-uploader-for-use-with-your-custom-object.html

Preethi SPreethi S
Thank u kevin....I got an idea from this.....