You need to sign in to do that
Don't have an account?
Hugo_B
Upload File to Document Object Need Help
I can't find a good code example that will allow me to have a VF page / site that let's a user (Customer Portal User) upload a document to a folder in the document object.
Any help greatly appreciated!!
Go through the sample code given below :
Controller:
public class ImageLoaderClass
{
public String fileName{get;set;}
public Blob theBlob{get;set;}
Public ImageLoaderClass()
{
}
public PageReference imageUpload()
{
Document d=new Document();
d.Body=this.theBlob;
d.Name=this.fileName;
d.FolderId='00lS0000000Qjcj'; // Here this is the folderId(you can access it at run time)
insert d;
return null;
}
}
VF Page:
<apex:page Controller="ImageLoaderClass">
<apex:sectionHeader title="Image Uploader" subtitle="New Image"/>
<apex:form >
<apex:pageBlock>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Image</apex:outputLabel>
<apex:inputFile fileName="{!fileName}" value="{!theBlob}"></apex:inputFile>
</apex:pageBlockSectionItem>
<apex:commandButton value="Upload" action="{!imageUpload}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Hope this helps.