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
Vivek Need helpVivek Need help 

How to upload Image using Input File tag in Visual Force.

Hello Every one ,

 

I am trying to upload Image using the Visual Force input tag, The problem I am facing is when I click on the document "Click to view the file " Link it show a 0 byte file .

 

Visual Force Code:-

<apex:pageBlockSection title="Upload Logo " columns="1" collapsible="true">
            <apex:inputFile value="{!document.body}" filename="{!document.name}" filesize="10"/>
</apex:pageBlockSection>

 

Controller Code:-

 

document = new Document();
          document.folderid = UserInfo.getUserId(); //store in Personal Documents
          document.Name = 'Company Logo';
          document.Type    ='gif';
          insert document;

 Please let me know what I am doing wrong.

 

Thanks and Regards

Vivek Manchanda

metaforcemetaforce

I wrote a sample code that uploads a file. Check out the page and the controller class in the zip file at the following location:

 

File Upload Sample Code

 

Let me know if you need any further help. 

paul-lmipaul-lmi
also, i'm pretty sure file uploads require a page refresh, so that could be why.