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
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 a url 
2.execute javascript 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

Please check below post with screen shot
<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="{!}" id="fileName"/>
        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!document.body}" filename="{!}" 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??