+ Start a Discussion
Andrea SloanAndrea Sloan 

How to Upload an image from documents to a VisualForce page

I've saveed my company logo in the Documents object of Salesforce. I want to insert this as the very first thing inside my VisualForce page on the Top Left and the have the line "Hello ...." appear (per the  coding below. I don't know how to insert an image. Do I needto reference the entire URL that the image is under within the Documents object? I know relative URLs would be better.  A_K_Logo_png is the name of my image /01523000000I3N9 is the relative URL  that it's found under.  How can I best accomlish this? Can someone  please repost my code for it to show up accordingly? I don't know how the syntax is to do this. I did not insert the entire code following hte beginning of a table that I posted but this is probably enough.

<apex:Page >
<apex:image url="{/01523000000I3N9}"></apex:image>
{apex:image:url"("A_K_Logo_png")" ;


        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/>
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css"/>
            $(function() {
                $("#pv2").datepicker({changeMonth: true, changeYear: true});
                 $("#pv12").datepicker({changeMonth: true, changeYear: true});          
                $(".datepick").datepicker({changeMonth: true, changeYear: true, constrainInput: false});      

   <FONT Size="3"><i> Hello  {! $User.FirstName}</i></FONT>
    <FONT Size="3"> <i>Please use the fields below to enter your desired dates for the specified reports.</i></FONT>
    <TABLE Border= "3" CELLSPACING="1" CELLPADDING="1" >
        <CAPTION><B> <FONT Size="4">Salesforce Reports</FONT> </B></CAPTION>
        <TR style="text-align:center;font-size:12pt;background-color:#ADD8E6;">
            <TD  >

parth jollyparth jolly
Hi Andrea,

A sample Visual Force page along with the custom controller. For this example, I have stored an image in the Document object with name"sample pic". You can add this VF page to layout of the page.
<apex:page controller="ImageController" showheader="false" sidebar="false">

      <apex:image url="{!imageURL}">

public with sharing class ImageController {
 public String imageURL{get;set;}

  public ImageController()
    List< document > documentList=[select name from document where 


Andrea SloanAndrea Sloan
Thank you, Parth. I will try it out. Would I put your entire code within the same page that I already have - the controller as wel/? Would I put it above my header tag? Also, what is better to store and grab an image from the Documents object or from the Static Resources? If it's from the  Documents object will it always be dependent on my user license being active for it to load?
Kalyan Babu DKalyan Babu D
Thanks parth.it worked for me.I want a little extension of this code.when we click on the image it shuld redirect to other url.Can u plz help me out