Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:pageBlockButtons >
- <apex:commandButton action="{!save}" value="Submit"/>
- <apex:commandButton action="{!cancel}" value="Cancel"/>
- </apex:pageBlockButtons>
- <apex:pageBlockSection title="Upload the Attachment" collapsible="false" dir="LTR" columns="1">
- <div id="upload" class="upload">
- <apex:inputFile id="fileToUpload" value="{!fileBody}" filename="{!fileName}" styleClass="input-file"/>
- </div>
- </apex:pageBlockSection>
- public class dataSheetAttachment
- {
- public Data_Feasibility_Request__c objdfr{get;set;}
- public Attachment myAttachment{get;set;}
- public string fileName{get;set;}
- public Blob fileBody{get;set;}
- public dataSheetAttachment(Apexpages.standardcontroller controller)
- {
- objdfr = (Data_Feasibility_Request__c)controller.getRecord();
- myAttachment = new Attachment();
- }
- public pagereference save()
- {
- if(myAttachment.Name == null)
- {
- insert objdfr;
- }
- if(myAttachment.Name != null)
- {
- insert objdfr;
- System.debug('@@@@@fileBody'+fileBody);
- myAttachment = new Attachment();
- Integer i=0;
- myAttachment .clear();
- myAttachment.Body = fileBody;
- myAttachment.Name = fileName ;
- myAttachment.ParentId = objdfr.id;
- insert myAttachment;
- }
- pagereference pr = Page.Thank_You;
- pr.setRedirect(true);
- return pr;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement