You need to sign in to do that
Don't have an account?
Embed VF Page which uses inputfile control in standard page
Hi,
I have created a VF Page as follows:
<apex:page standardController="Project__c" extensions="FileUploadController">
<apex:pageMessages />
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
</apex:page>
The following is code for extension.
public with sharing class FileUploadController {
public FileUploadController(ApexPages.StandardController controller) {
}
public Document document {
get {
if (document == null)
document = new Document();
return document;
}
set;
}
public PageReference upload() {
document.AuthorId = UserInfo.getUserId();
document.FolderId = UserInfo.getUserId(); // put it in running user's folder
try {
insert document;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
return null;
} finally {
document.body = null;
document = new Document();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
return null;
}
}
Now i need to embed the VF Page onto standard page. After adding it onto standard Page layout, when i click on browse button and select a file and click on OK, the button of the standard page is still displayed as edit, there is no option to save. Also when i click on edit button the VF Page is vanished.
Can anyone help. Help is needed ASAP or can this be done?