Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <apex:pageBlockButtons >
  2. <apex:commandButton action="{!save}" value="Submit"/>
  3. <apex:commandButton action="{!cancel}" value="Cancel"/>
  4. </apex:pageBlockButtons>
  5. <apex:pageBlockSection title="Upload the Attachment" collapsible="false" dir="LTR" columns="1">
  6. <div id="upload" class="upload">
  7. <apex:inputFile id="fileToUpload" value="{!fileBody}" filename="{!fileName}" styleClass="input-file"/>
  8. </div>
  9. </apex:pageBlockSection>
  10.  
  11. public class dataSheetAttachment
  12. {
  13. public Data_Feasibility_Request__c objdfr{get;set;}
  14. public Attachment myAttachment{get;set;}
  15. public string fileName{get;set;}
  16. public Blob fileBody{get;set;}
  17.  
  18. public dataSheetAttachment(Apexpages.standardcontroller controller)
  19. {
  20. objdfr = (Data_Feasibility_Request__c)controller.getRecord();
  21. myAttachment = new Attachment();
  22. }
  23. public pagereference save()
  24. {
  25. if(myAttachment.Name == null)
  26. {
  27. insert objdfr;
  28. }
  29. if(myAttachment.Name != null)
  30. {
  31. insert objdfr;
  32. System.debug('@@@@@fileBody'+fileBody);
  33. myAttachment = new Attachment();
  34. Integer i=0;
  35. myAttachment .clear();
  36. myAttachment.Body = fileBody;
  37. myAttachment.Name = fileName ;
  38. myAttachment.ParentId = objdfr.id;
  39. insert myAttachment;
  40. }
  41. pagereference pr = Page.Thank_You;
  42. pr.setRedirect(true);
  43. return pr;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement