public with sharing class ImageController { public String imageURL{get;set;}
public ImageController() { imageURL='/servlet/servlet.FileDownload?file='; List< document > documentList=[select name from document where Name='Girl'];
public String textName{get;set;} public ID folderid{get;set;} public Blob file{get;set;}
public PageReference insrt() {
Document d= new Document();
d.name = naam; d.body=file; // body field in document object which holds the file. d.folderid='00l90000001SuJs'; //folderid where the document will be stored insert d;
insert d;
con=true;
List<Document> attachedFiles = [select d.Id,d.body,d.Name from Document d order by Id Desc limit 1]; if( attachedFiles != null && attachedFiles.size() > 0 ) { fileId = attachedFiles[0].Id;
public String textName{get;set;} public ID folderid{get;set;} public Blob file{get;set;}
public PageReference insrt() {
Document d= new Document();
d.name = textName; d.body=file; // body field in document object which holds the file. d.folderid='00l90000001SuJs'; //folderid where the document will be stored insert d;
insert d;
con=true;
List<Document> attachedFiles = [select d.Id,d.body,d.Name from Document d order by Id Desc limit 1]; if( attachedFiles != null && attachedFiles.size() > 0 ) { fileId = attachedFiles[0].Id;
Hello,
Please refer following links for code snippets:
http://salesforcetrekbin.blogspot.in/2010/04/visualforce-file-upload-for-any-sobject.html
http://boards.developerforce.com/t5/Visualforce-Development/Image-Upload-using-visualforce-and-saving-in-custom-formula/td-p/335421
Hey Hi ,
Kindly check this code .Using std ctrll and IFRAMES
<apex:page standardController="Image__c" sidebar="false" showHeader="false">
<div>
<center>
<!--<apex:iframe src="https://www.gmail.com/" width="800" height="600"/>-->
<!--<apex:iframe src="https://ap1.salesforce.com/01Z90000000E5ME?isdtp=nv" scrolling="true" height="1000px" width="100%"/>-->
<!--<apex:iframe src="http://1.bp.blogspot.com/-1MRrHsxohsE/UWDZtHYWV-I/AAAAAAAAAl0/yl00tyzvKds/s1600/Baby-Girl-Wallpaper-2.jpg" scrolling="true" height="500px" width="1000%"/>-->
<!-- This is to add an video in vf page -->
<apex:iframe width="420" height="315" src="http://www.youtube.com/embed/Qd8OtvSgal8"/>
<!-- <apex:flash play="true" loop="true" src="http://www.tizag.com/pics/example.swf" height="300" width="50%" />-->
</center>
</div>
</apex:page>
This is another option using image and calling it from documents
<apex:page controller="ImageController" showheader="false" sidebar="false">
<apex:form >
<center>
<apex:image url="{!imageURL}">
</apex:image>
</center>
</apex:form>
</apex:page>
public with sharing class ImageController {
public String imageURL{get;set;}
public ImageController()
{
imageURL='/servlet/servlet.FileDownload?file=';
List< document > documentList=[select name from document where
Name='Girl'];
if(documentList.size()>0)
{
imageURL=imageURL+documentList[0].id;
}
}
}
Vf Page
<apex:page controller="ImagInsertionIntoRichText">
<apex:form >
<apex:outputLabel value="Document Name"></apex:outputLabel>
<apex:inputText id="name" value="{!textName}"/>
<apex:outputLabel value="Upload Document"></apex:outputLabel>
<apex:inputfile value="{!file}"></apex:inputfile>
<apex:commandButton value="Save" action="{!insrt}" id="save"/>
<apex:image url="/servlet/servlet.FileDownload?file={!FileId}" height="100" width="100" rendered="{!con}"></apex:image>
</apex:form>
</apex:page>
Class
public class ImagInsertionIntoRichText
{
public string FileId { get; set; }
public String getFileId;
public boolean con { get; set; }
public String textName{get;set;}
public ID folderid{get;set;}
public Blob file{get;set;}
public PageReference insrt()
{
Document d= new Document();
d.name = naam;
d.body=file; // body field in document object which holds the file.
d.folderid='00l90000001SuJs'; //folderid where the document will be stored insert d;
insert d;
con=true;
List<Document> attachedFiles = [select d.Id,d.body,d.Name from Document d order by Id Desc limit 1];
if( attachedFiles != null && attachedFiles.size() > 0 ) {
fileId = attachedFiles[0].Id;
}
return null;
}
}
Vf Page
<apex:page controller="ImagInsertionIntoRichText">
<apex:form >
<apex:outputLabel value="Document Name"></apex:outputLabel>
<apex:inputText id="name" value="{!textName}"/>
<apex:outputLabel value="Upload Document"></apex:outputLabel>
<apex:inputfile value="{!file}"></apex:inputfile>
<apex:commandButton value="Save" action="{!insrt}" id="save"/>
<apex:image url="/servlet/servlet.FileDownload?file={!FileId}" height="100" width="100" rendered="{!con}"></apex:image>
</apex:form>
</apex:page>
Class
public class ImagInsertionIntoRichText
{
public string FileId { get; set; }
public String getFileId;
public boolean con { get; set; }
public String textName{get;set;}
public ID folderid{get;set;}
public Blob file{get;set;}
public PageReference insrt()
{
Document d= new Document();
d.name = textName;
d.body=file; // body field in document object which holds the file.
d.folderid='00l90000001SuJs'; //folderid where the document will be stored insert d;
insert d;
con=true;
List<Document> attachedFiles = [select d.Id,d.body,d.Name from Document d order by Id Desc limit 1];
if( attachedFiles != null && attachedFiles.size() > 0 ) {
fileId = attachedFiles[0].Id;
}
return null;
}
}
You may find this useful
http://blog4sfdc.blogspot.in/2013/11/uploading-image-in-salesforce-through.html