Thanks Ramu.... I struggled in controller for upload method... I created text field for photo...After clicking upload button that the controller save image into this field...can u help me for this?
<apex:page standardController="BioBr__c" tabStyle="BioBr__c" sidebar="false" extensions="controllerExtension"> <apex:sectionHeader title="Attach File"/> <apex:form > <apex:pageBlock title="AttachFile" mode="edit"> <apex:pageBlockSection showHeader="false" columns="1" id="block1"> <apex:outputLabel value="1.Select the file" for="fileName"/> Type the Path of the file or Click the browse button to find attachment <apex:inputFile value="Browse" fileName="{!BioBr__c.Photo__c}" id="fileName"/>
<h1>2.Click the "Attach File" button.</h1> <p>Repeat steps 1 and 2 to attach multiple files </p> <p>(When the upload is completed the file information will appear below)</p><br/> <apex:commandButton value="Attach File" action="{!upload}"/> <br/> <h1>3.Click the Done button to return to the previous page</h1> <p>(This will cancel an in-progress upload. )</p><br/> <apex:commandButton value="Done" action="{!save}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
I created controller below But it is not working properly...I think i have mistake in upload method...Can u help me for this?
public class controllerExtension{ public controllerExtension(ApexPages.StandardController controller) {
} public BioBr__c bio{ get { if (bio == null) bio = new BioBr__c(); return bio; } set; }
public PageReference save(){ PageReference acctPage = new ApexPages.StandardController(bio).view(); acctPage.setRedirect(true); return acctPage; } public PageReference upload(){
https://success.salesforce.com/answers?id=90630000000glUkAAI
https://success.salesforce.com/answers?id=90630000000hX8VAAU
I struggled in controller for upload method...
I created text field for photo...After clicking upload button that the controller save image into this field...can u help me for this?
<apex:page standardController="BioBr__c" tabStyle="BioBr__c" sidebar="false" extensions="controllerExtension">
<apex:sectionHeader title="Attach File"/>
<apex:form >
<apex:pageBlock title="AttachFile" mode="edit">
<apex:pageBlockSection showHeader="false" columns="1" id="block1">
<apex:outputLabel value="1.Select the file" for="fileName"/>
Type the Path of the file or Click the browse button to find attachment
<apex:inputFile value="Browse" fileName="{!BioBr__c.Photo__c}" id="fileName"/>
<h1>2.Click the "Attach File" button.</h1>
<p>Repeat steps 1 and 2 to attach multiple files </p>
<p>(When the upload is completed the file information will appear below)</p><br/>
<apex:commandButton value="Attach File" action="{!upload}"/>
<br/>
<h1>3.Click the Done button to return to the previous page</h1>
<p>(This will cancel an in-progress upload. )</p><br/>
<apex:commandButton value="Done" action="{!save}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
But it is not working properly...I think i have mistake in upload method...Can u help me for this?
public class controllerExtension{
public controllerExtension(ApexPages.StandardController controller) {
}
public BioBr__c bio{
get {
if (bio == null)
bio = new BioBr__c();
return bio;
}
set;
}
public PageReference save(){
PageReference acctPage = new ApexPages.StandardController(bio).view();
acctPage.setRedirect(true);
return acctPage;
}
public PageReference upload(){
try {
system.debug('++++++++' +bio);
insert bio;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
return null;
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
return null;
}
}
Hi Preethi,
Have you looked at this post?
https://developer.salesforce.com/blogs/labs/2010/07/how-to-update-picture-uploader-for-use-with-your-custom-object.html