+ Start a Discussion
Supriyo Ghosh 5Supriyo Ghosh 5 

Image upload


I want to create a button through which I will upload a image in a standard page layout.Is it possible.Please help
You can only do three actions on the standard page with custom button 

1.call a url 
2.execute javascript
3.call VF page 

I am not sure what your uploading an Image means ? but If you are trying to provide an Upload wizard to the user and then upload the file you have to go through the VF page approach .

Hope this helps.

Amit Chaudhary 8Amit Chaudhary 8
Please check below post for code
1) https://developer.salesforce.com/forums/?id=906F000000097OVIAY
2) http://blog.jeffdouglas.com/2010/04/22/uploading-a-document-using-visualforce-and-a-custom-controller/
3) http://developer.force.com/cookbook/recipe/uploading-a-document-using-visualforce-and-a-custom-controller
4) http://ezdhanhussain.blogspot.in/2013/11/uploading-image-in-salesforce-through.html

Please check below post with screen shot
5) http://forceguru.blogspot.in/2011/06/display-picture-in-contact.html
<apex:page controller="FileUploadController">
  <apex:sectionHeader title="Visualforce Example" subtitle="File Upload Example"/>
  <apex:form enctype="multipart/form-data">
    <apex:pageMessages />
    <apex:pageBlock title="Upload a File">
      <apex:pageBlockButtons >
        <apex:commandButton action="{!upload}" value="Save"/>
      <apex:pageBlockSection showHeader="false" columns="2" id="block1">
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!document.name}" id="fileName"/>
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Description" for="description"/>
          <apex:inputTextarea value="{!document.description}" id="description"/>
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="Keywords" for="keywords"/>
          <apex:inputText value="{!document.keywords}" id="keywords"/>
public with sharing class FileUploadController {
  public Document document {
    get {
      if (document == null)
        document = new Document();
      return document;
  public PageReference upload() {
    document.AuthorId = UserInfo.getUserId();
    document.FolderId = UserInfo.getUserId(); // put it in running user's folder
    try {
      insert document;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
      return null;
    } finally {
      document.body = null; // clears the viewstate
      document = new Document();
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
    return null;

Let us know if this will help you

Amit Chaudhary
Supriyo Ghosh 5Supriyo Ghosh 5
Hi @Amit I have standrad page in Standrad object case managment.My objective is when a end user create a case that time in that standrad page layout having a Upload button through which they can upload a n Image and if they are not uploading then they cannot able to save that one.

Is this possible through that standrad page layout or I have to go for vf page??