function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chokchok 

Displaying attachment in Visualforce page

Hi,

 

How can I display an attachment on Visualforce page that can be downloadable.

 

 

Thanks in advance!

Big VBig V

I am sure what is your exact requirement. But in general you can provide a link for downloading attachment by Global $Action variable.

Eg:

 

<apex:outputLink
value="{!URLFOR($Action.Attachment.Download,att.id)}">
Download Now!
</apex:outputLink>

 where attachment is your attachment record.

 

 

 

Big V

 

 

Varun99Varun99

Hi Big V,

 

My requirement is also same. i want display my attachment in vf page

in output link with download and also View file also

As like gmail attachment

am using your code it raise an error like

 

Visualforce Error
 


Invalid parameter for function URLFOR

Error is in expression '{!URLFOR($Action.Attachment.Download,a.id)}' in component <apex:componentReference> in page candidateinfo
 
Can you please help me
 
 
Thank you
PremanathPremanath

Try This

 

 

<apex:outputLink value="{!URLFOR($Action.Attachment.Download, attachment.id)}" target="_blank">{!attachment.name}</apex:outputLink>

 

 

Prem