I have simple action: save image as attachment. I do it by actionFunction and I don't need to reload page when I click SAVE button. And when I add attr reRender in actionFunction statement then file from inputFile doesn't exist. When I delete reRender attachment saves but page reload. What can I do for save file from inputFile and don't reload page. I added actionRegion because apex:inputFile can't be used in conjunction with actionFunction. I repeat part of my comment here: if you can't help just do nothing. Do not try to prove that you are very clever and know something when it is not. I will not explain difference between my question and another so if you don't understand it then you'll not understand difference between cow and frog.

This is my code.

VF page:

<div id="addScheduleBlock">
        <apex:actionFunction name="callSaveSchedule" action="{!saveSchedule}" status="initScheduleBlock"/>
        <apex:outputLabel value="Date"  for="sheduledate"/>
        <apex:input type="date" value="{!scheduleDateForSave}" required="true" id="sheduledate"/>
        <input type="button" value="Save" disabled="true" id="saveScheduleButton"/>
    <apex:inputFile value="{!attachedFile.body}" filename="{!attachedFile.Name}" id="sheduleImg" accept="image/*"/>


function saveSchedule(){
  $("#saveScheduleButton").on( "click", function() {
    if (confirm('Are you shure?')) {
    } else {
      return false;

Apex Controller:

public PageReference saveSchedule() {
    List<Schedule__c> scheduleToDelete = [SELECT Id FROM Schedule__c WHERE ScheduleDate__c =: scheduleDateForSave];
    delete scheduleToDelete;
    schedule.ScheduleDate__c = scheduleDateForSave;
    insert schedule;
    attachedFile.ParentId = schedule.Id;
    insert attachedFile;  
    schedule = new Schedule__c();
    attachedFile = New Attachment();
    return null;
  • apex:inputFile can't be used in conjunction with an action component when i'm trying to delete a row – it's not the same question. I know that I can't use reRender with conjunction to inputFile. – Dmitry Oct 10 '16 at 10:32
  • Is there a particular reason you want the page not to reload? – Guy Clairbois Oct 10 '16 at 10:55
  • Yes. When page reloads I lose all opened and loaded information, loading start page and I must to do some actions again. – Dmitry Oct 10 '16 at 10:57
  • I'm not sure why this was marked as a duplicate, but I think the answer OP wants is in a different question here. Basically, you'll need to use an AJAX call to update the data without a post back, Visualforce Remoting may work but the REST API will allow you to upload larger files. – IllusiveBrian Oct 10 '16 at 15:23
  • I think when you click duplicated you didn't read question at all. If you can't help don't need to let on that you very smart and it's very easy for you. Just do nothing or give useful advice. Thank you IllusiveBrian. I know this way and will do so. But I thought that someone can help me to solve problem by using default SF tools. – Dmitry Oct 10 '16 at 16:47