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

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:inputFile value="{!document.body}" filename="{!}"/>
            <apex:commandButton value="save" action="{!save1}"/>
            <apex:param name="q" value="{!}"/> <!Tried using this -->
Controller Code:::
public class documentExt {
String path;
ApexPages.StandardController controller;       
public documentExt(ApexPages.StandardController controller)
               Document d = (Document) controller.getRecord();
               d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents
// ** Overriding the save method **  
public PageReference save1()
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
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 property for you when your action method save1() is invoked.
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:

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

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