You need to sign in to do that
Don't have an account?
Aloke Singh 6
Want to add attached document link to VF page for download or view
I have created a VF page on case to upload a file and using standard controller with extension. When user will upload a file from VF page then the attached file will be stored to a different custom object's(Custom Object is look up relationship with Case) notes and attachement. Till this everything is fine. Now my requirement is that add a attached document link to VF page so that user can download the file. I am using the below mentioned code in VF and able to see the link but it disappear when page refresh. I want to add permananetly so that user can access later as well.
<a href="/servlet/servlet.FileDownload?file={!myAttachment.id}" download="{!myAttachment.name}">{!myAttachment.name}</a>
Please help on this.
<a href="/servlet/servlet.FileDownload?file={!myAttachment.id}" download="{!myAttachment.name}">{!myAttachment.name}</a>
Please help on this.
I've gone through your requirement and you should see the below code for reference:
Visualforce--->
<apex:page controller="AttachmentClass">
<a href="{!URLFOR($Action.Attachment.Download, attachmentId)}" class="btn btn-info">
<span class="glyphicon glyphicon-save-file"></span> Download </a>
<br/><br/>
<a href="#" class="btn btn-info" onclick="return window.open('{!URLFOR($Action.Attachment.Download, attachmentId)}','_top');">
<span class="glyphicon glyphicon-save-file"></span> Preview</a>
</apex:page>
Apex class--->
public class AttachmentClass{
public string attachmentid {get; set;}
public AttachmentClass(){
attachmentid='0018000001AcqAX';
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com