Page :
<apex:inputFile value=”{!attachBody}” filename=”{!attach.name}”></apex:inputFile>
<apex:button value=”Save” action=”{!saveProfitandLossStatement}” />
class:
public Attachment attach{get;set;}
public transient blob attachBody{get;set;}
public PageReference saveProfitandLossStatement(){ //to add more payers..
PageReference pg=null;
attach.parentId = appRecord.id;
attach.body = attachBody;
insert attach;
pg = new PageReference(URL.getSalesforceBaseUrl().toExternalForm()+’/apex/ViewApplicationsRecord?guid=’+appRecord.id);
pg.setRedirect(true);
return pg;
}
appRecord.id is the id get from URL.