Uploading a Document into Salesforce using Visualforce

3:27 PM

In this article we will be understanding the procedure to upload a file into "Documents" using a Visualforce Page. You can upload a file and save it as an attachment against a record i believe, but i am not sure how to do this. Hence, this topic would only cover uploading a file to "Documents" under a folder you desire.

I actually had to upload a file against a record. I uploaded the file into Documents, and then stored the reference of the file as a Field in the record. This way i can access the document from the record directly at a later point.

Create a field called DocumentId in your object.. When you insert the document after upload, store this ID in the new field you created.. Later, you can navigate to the document by using the URL .. '/DocumentId'

Ablove code si working fine for me but I am facing isssue.1- whn i am uploding the file thn the contentType is null for all the uploaded files.how to get the ContentType of the file..you can run the given below query.SELECT Name,AuthorId ,type,Keywords,Url,BodyLength,Body ,FolderId FROM Document