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
udayarangareddy mekalaudayarangareddy mekala 

ATTATCHEMENT FILE

Hi
<apex:inputField value="{!Empolyee_Details__c.name}"/>
                  <apex:inputfile value="{!Empolyee_Details__c.ID}" filename="{!Empolyee_Details__c.name}"></apex:inputfile>
 i wrote the above statements which  will come as CHOOSE FILE option.Through CHOOSE FILE option i uploaded file but it was showing ERROR.please tell me solution.

THANKS

RANGA
        
        

Best Answer chosen by udayarangareddy mekala
Muthuraj TMuthuraj T
<apex:inputfile value="{!att.Body}"></apex:inputfile>
Controller:

Attachment att = new Attachment();



Hi,
Use the above code and let me know if it is solved your issue.

All Answers

Alexander TsitsuraAlexander Tsitsura
Hi udayarangareddy,

You need create Document/Attachment property in constructor and when  user click save you need insert in database new document/attachment
Please see code below
 
<!-- Upload a file and put it in your personal documents folder-->

<!-- Page: -->
<apex:page standardController="Document" extensions="documentExt">
    <apex:messages />
    <apex:form id="theForm">
      <apex:pageBlock>
          <apex:pageBlockSection>
            <apex:inputFile value="{!document.body}" filename="{!document.name}"/>
            <apex:commandButton value="Save" action="{!save}"/>
          </apex:pageBlockSection>
       </apex:pageBlock>
    </apex:form>
</apex:page>
                
/*** Controller ***/
public class documentExt {
    public documentExt(ApexPages.StandardController controller) {
        Document d = (Document) controller.getRecord();
        d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents
    }                 
}


As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you.

Thanks,
Alex
Alexander TsitsuraAlexander Tsitsura
And u can see Attachemnt example here http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/
Muthuraj TMuthuraj T
<apex:inputfile value="{!att.Body}"></apex:inputfile>
Controller:

Attachment att = new Attachment();



Hi,
Use the above code and let me know if it is solved your issue.
This was selected as the best answer
udayarangareddy mekalaudayarangareddy mekala

Thanks MUTHURAJ
The above two statements i mentioned in myVF PAGE n CONTROLLER which shows the CHOOSE FILE option.whenever i was going to upload any file i got below message.
value 'core.filemanager.FileBlobValue@4b238c6d' cannot be converted from core.filemanager.FileBlobValue to lib.id.ID
Error is in expression '{!Empolyee_Details__c.id}' in component <apex:inputFile> in page employee_create_page
THANKS

RANGA