You need to sign in to do that
Don't have an account?
rajesh_y
How to provide file download facility in visual force page
Hi
i wants to provide facility to files which i uploaded
i wants implement this in visualforce page
please put code also
thanks in advance
rajesh
How have you uploaded the files? I.e. are they attachments to records, in the Documents tab, chatter files etc?
Assuming its an attachment, you can simply output a link, e.g. if you have access to the attachment in a property named 'attachment', you can do the following:
All Answers
How have you uploaded the files? I.e. are they attachments to records, in the Documents tab, chatter files etc?
Assuming its an attachment, you can simply output a link, e.g. if you have access to the attachment in a property named 'attachment', you can do the following:
You mean like this?
http://boards.developerforce.com/t5/Visualforce-Development/Uploading-document-from-visualforce-page/td-p/174592
Hi Bob,
I have tried this code. Its working for me. But it is shows the code in another tab of the browser. But i need to down load the attchement. How can i download the attachement.
Thanks,
Lakshmi
I suspect that's because the browser knows how to handle that particular type of file. In that case you have to right click the link and choose 'save as' or similar.
Hi Bob,
Thanks for your reply,
Is it not possible to download directly through command button, with right click and save.
Thanks,
Lakshmi
The problem here is that its controlled by the browser. The only way I'm aware of to achieve this is to set the Content-Disposition header on the HTTP response, but you don't have access to that from Apex/Visualforce.
Hi,
I am new to Salesforce. My requirement is when the user clicks on the link the file has to download from Static resource. Can any one help on this?
You can do that using below code
<a href="{!URLFOR($Resource.Templatefile)}" target="_blank"> Click here </a>
where Templatefile is your static resource name.
Thanks Champ. Now it is working fine...
Do something like the following in your VFP controller constructor
ApexPages.currentPage().getHeaders().put('Content-Disposition', 'attachment; filename="Setup.exe"');
Visualforce page:
Visualforce controller: