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
udayarangareddy mekalaudayarangareddy mekala 

Image uploading

VF PAGE

-----------
<apex:page standardController="Empolyee_Details__c" extensions="EmployeeRelatedList" tabStyle="Empolyee_Details__c">
  <apex:form >
    <apex:sectionHeader title="EmployeeInfo"/>
    <apex:pageBlock title="EmployeeData">

       

        <apex:pageBlockSection title="Empolyee basic Details" columns="2" collapsible="false">

              <apex:outputField value="{!Empolyee_Details__c.EmpId__c}"/>
            <apex:inputField value="{!Empolyee_Details__c.FirstName__c}"/>

            <apex:inputField value="{!Empolyee_Details__c.LastName__c}"/>
             <apex:inputField value="{!Empolyee_Details__c.MiddleName__c}"/>

            <apex:inputField value="{!Empolyee_Details__c.DateofBirth__c}"/>
             <apex:inputField value="{!Empolyee_Details__c.FatherMotherhusbandName__c}"/>

            <apex:inputField value="{!Empolyee_Details__c.MartialStatus__c}"/>

        </apex:pageBlockSection>

        <apex:pageBlockSection title="Empolyee office Details" columns="2" collapsible="false">

            <apex:inputField value="{!Empolyee_Details__c.Current_Designation__c}"/>

            <apex:inputField value="{!Empolyee_Details__c.Current_Office__c}"/>
            
            <apex:inputField value="{!Empolyee_Details__c.Current_Cadre__c}"/>

        </apex:pageBlockSection>
      
      <apex:pageBlockSection title="Present Address Detail" columns="2" collapsible="false">
      
      <apex:inputField value="{!Empolyee_Details__c.Present_Address__c}"/>
       <apex:inputField value="{!Empolyee_Details__c.State__c}"/>
       <apex:inputField value="{!Empolyee_Details__c.District__c}"/>
        <apex:inputField value="{!Empolyee_Details__c.Phone_Number__c}"/>
         <apex:inputField value="{!Empolyee_Details__c.Mobile_Number__c}"/>
          <apex:inputField value="{!Empolyee_Details__c.Pin_Code__c}"/>
          <apex:inputField value="{!Empolyee_Details__c.E_mail_if_any__c}"/>
          
      </apex:pageBlockSection>  

          <apex:pageBlockSection title="Perment Address Detail" columns="2" collapsible="false">
              <apex:inputField value="{!Empolyee_Details__c.Permanent_Address__c}"/>
              <apex:inputField value="{!Empolyee_Details__c.State_p__c}"/>
              <apex:inputField value="{!Empolyee_Details__c.District_p__c}"/>
              <apex:inputField value="{!Empolyee_Details__c.Pin_Code_p__c}"/>
              <apex:inputField value="{!Empolyee_Details__c.Phone_Number_p__c}"/>
              <apex:inputField value="{!Empolyee_Details__c.Mobile_Number_p__c}"/>
              
   </apex:pageBlockSection>
           <apex:pageblockSection title="Joing Details" collapsible="false">
               <apex:inputField value="{!Empolyee_Details__c.Date_of_Joining__c}"/>
               <apex:inputField value="{!Empolyee_Details__c.Date_of_Leaving__c}"/>
      </apex:pageblockSection>
        <apex:pageBlockSection title="Basic" collapsible="false">
           <apex:inputField value="{!Empolyee_Details__c.Education__c}"/>
            <apex:inputField value="{!Empolyee_Details__c.Name_of_Board_University__c}"/>
             <apex:inputField value="{!Empolyee_Details__c.Marks_Obtained_In__c}"/>
             <apex:inputField value="{!Empolyee_Details__c.Passing_Year__c}"/>
             <apex:inputField value="{!Empolyee_Details__c.Stream__c}"/>
              <apex:inputField value="{!Empolyee_Details__c.Grade__c}"/>
            
         </apex:pageBlockSection>
        

            
<apex:inputFile filename="{!fileName}"   value="{!resume}"/>
  <apex:image url="{!imageURL}"/>
              

          <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="SAVE"/>
        </apex:pageBlockButtons>

      

    </apex:pageBlock>
Controller
--------------
public class EmployeeRelatedList {
 private Empolyee_Details__c empDetail;
  public blob picture{get;set;}
 public Blob resume {get; set;}
 public String fileName {get; set;}
 public string imageURL{get; set;}

 
 
    public EmployeeRelatedList(ApexPages.StandardController stdController) {
     
        this.empDetail = (Empolyee_Details__c)stdController.getRecord();
   
 
    }
    
    
  public EmployeeRelatedList(){
       imageURL='/servlet/servlet.FileDownload?file=';
       List< document > documentList=[select name from document where
Name='picture'];
if(documentList.size()>0)
{
imageURL=imageURL+documentList[0].id;
}

 
 
  }
    
    public Pagereference save(){
       

       
        try{



        
        
           
                   
               
            upsert empDetail;
            return new Pagereference('/apex/Custom_pagenations');
            }
            
          

        
        catch(Exception e){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, e.getMessage()));
            return null;
        }
        
     
     
     
   
    }
    
}
For above VF PAGE and CONTROLLER ie the employee registration form.for that i want to upload the image. can u please tell the code for the how to upload the image.





Regards
Rangareddy

 

James LoghryJames Loghry
Here's one of many examples I came cross through a simple search:

https://developer.salesforce.com/forums/?id=906F000000097OVIAY