You need to sign in to do that
Don't have an account?
DannyK89
Adding an Attachment to a visual force page.
I would like to add an attachments section to my custom visual force page. I would also like to display the attachment on the next page. Here is what I have so far. Please steer me in the right direction
<apex:page controller="leadController" tabStyle="Referral__c"> <script> function confirmCancel() { var isCancel = confirm("Are you sure you wish to cancel?"); if (isCancel) return true; return false; } </script> <apex:sectionHeader title="Lead Informaiton" subtitle="Step 2 of 3"/> <apex:relatedList list="NotesAndAttachments"/> <apex:form > <apex:pageBlock title="Candidate Information" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!Leadstep3}" value="Next"/> <apex:commandButton action="{!Leadstep1}" value="Previous"/> <apex:commandButton action="{!leadcancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Candidate Information"> <apex:inputField id="candidateName" value="{!referral.Candidate_Name__c}"/> <apex:inputField id="candidateEmail" value="{!referral.Candidate_Email__c}"/> <apex:inputField id="candidatecellPhone" value="{!referral.Candidate_Cell_Phone__c}"/> <apex:inputField id="candidateCity" value="{!referral.Candidate_City__c}"/> <apex:inputField id="candidateState" value="{!referral.Candidate_State__c}"/> <apex:inputField id="areaofExperties" value="{!referral.Area_of_Expertise__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
I think it should work pretty much the same way if it's an image or a Word document.
You might want to try these links. They might actually be more helpful than uploading my code since they are more simpler since I have several other things in mine that might make it a bit more confusing such as limit the upload size of an image as well as allow users to only upload 7 pictures.
http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/
http://salesforcetrekbin.blogspot.com/2010/04/visualforce-file-upload-for-any-sobject.html
Let me know if this helps or you need any other ideas!
I should also mention, maybe you already knew or figured, but each attachment must be associated with a record in the URL like www.mydomain.com/page?id={object__c.id}
All Answers
Maybe this will help some... This page allows users to upload an image attachment and then after uploading an image the page just automatically refreshes and a thumbnail of the image is displayed. Do you also need the controller, or were you just looking for how to do it in VF?
I was looking for a way to upload a word object. If that makes a diffence also a controller would help.
I think it should work pretty much the same way if it's an image or a Word document.
You might want to try these links. They might actually be more helpful than uploading my code since they are more simpler since I have several other things in mine that might make it a bit more confusing such as limit the upload size of an image as well as allow users to only upload 7 pictures.
http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/
http://salesforcetrekbin.blogspot.com/2010/04/visualforce-file-upload-for-any-sobject.html
Let me know if this helps or you need any other ideas!
I should also mention, maybe you already knew or figured, but each attachment must be associated with a record in the URL like www.mydomain.com/page?id={object__c.id}