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
Rahul456Rahul456 

what syntax to use to get a file name,of which I am uploading using Input File,plz suggest ASAP

For suppose path of the file I am uplaoding is the below one:
C:\Documents and Settings\rajnoot\Desktop\login.txt
 
Here Name of the file is login.txt,So how to retrieve this file name,when I am uploading this file.
 
I used below Code:But it is not working::::
 
Page Editor Code:::
 
<apex:page StandardController="Document" extensions="documentExt">
   
    <apex:form >
      <apex:pageBlock >
          <apex:pageBlockSection>
            <apex:inputFile value="{!document.body}" filename="{!document.name}"/>
            <apex:commandButton value="save" action="{!save1}"/>
            <apex:param name="q" value="{!document.name}"/> <!Tried using this -->
                   </apex:pageBlockSection>
       </apex:pageBlock>
    </apex:form>
</apex:page>
 
Controller Code:::
 
public class documentExt {
String path;
ApexPages.StandardController controller;       
public documentExt(ApexPages.StandardController controller)
   {
              this.controller=controller;
               Document d = (Document) controller.getRecord();
               d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents
     }       
// ** Overriding the save method **  
    
public PageReference save1()
{
controller.save();
path=System.currentPageReference().getParameters().get('q');
System.debug('Uplaoded File Name is:::'+ path); /*showing path Value as NULL*/
return page.docsample;
}        
}
 
 
Please Suggest me,How to get file name in path variable
dchasmandchasman
You're making things more complicated than they need to be. The apex:inputFile fileName value binding is bidirectional and is already automatically setting the document.name property for you when your action method save1() is invoked.
esaesa
Is there a way to get the full path of the file? With an S-Control you could get access to the full path and file name with the following:

HTML:
<input type="file" id='FilePath' name='FilePath'>

S-CONTROL:
var filePath = document.getElementById('FilePath').value;

How do we do the same with Visualforce?

Message Edited by esa on 01-19-2009 11:11 PM