This is my apex class
public class ClaimAttachment_1 {
public Id recId{get;set;}
public String contIdChosen {get; set;}
public Attachment attachment {get;set;}
public string fileName{
get;set;}
public Blob fileBody {
get;set;}
public string contentType {
get;set;}
public ClaimAttachment_1(ApexPages.StandardController controller){
recId = controller.getRecord().Id;
attachment = new Attachment();}
public List<Attachment> getAttachments(){
string AttParentId = apexPages.currentPage().getParameters().get('id');
list<attachment> att = [select Id,Name,BodyLength,CreatedDate,CreatedById,OwnerId,contentType from Attachment where parentId =:AttParentId ];
return att;}
public PageReference returnPage(){
return Page.ClaimAttachment_1;}
public PageReference UploadFile()
{
PageReference pr;
if(fileBody != null && fileName != null)
{
attachment.Body = fileBody;
attachment.Name = fileName;
attachment.contentType = contentType;
attachment.ParentId = recId;
insert attachment;
// pr = new PageReference('/' + myAttachment.Id);
//pr.setRedirect(true);
// return pr;
return Page.ClaimAttachment;
}
return null;
}
public PageReference delCont(){
attachment toDel=new attachment(id=contIdChosen);
delete todel;
return null;}
public PageReference Back()
{
return Page.ClaimAttachment;
}
}