You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by elyes sallem <el...@gmail.com> on 2008/12/11 11:20:33 UTC

initialise a form file

Hello,
in a form, a define a <html:file
and i defined a form file as property
i wanna initialise the path and display it in first access
i have the value of the path by default
i will initialise it in the default constructor of the actionForm
but i don't know how affect a path to FormFile
assume that the property is
FormFile scopeFile
and the default path is, c:\dev\scope.cvs
how can i initialise scope to this path?

Thanks in advance
Elyes

Re: initialise a form file

Posted by Dave Newton <ne...@yahoo.com>.
--- On Thu, 12/11/08, Robert Graf-Waczenski wrote:
> No, the absolute path is not available and also completely
> irrelevant to a web application because the absolute path 
> as seen by the client who uploaded the file may or may not 
> be the same to another client who looks at the uploaded data.

In addition, the path supplied by the browser is browser-dependent: some browsers provide the full path on the client, some only provide the filename.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: initialise a form file

Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
No, the absolute path is not available and also completely irrelevant to 
a web application because the absolute path as seen by the client who 
uploaded the file may or may not be the same to another client who looks 
at the uploaded data. Again, this is due to how file uploads via HTTP 
work. The browser simply does not supply the information about the 
absolute path, so the web application is unable to display this 
information. The only way you would possibly get this kind of 
information would be a java applet, but this is way off topic for this list.

Robert

elyes sallem wrote:
> OK, thanks for your response
> if i understood well, there is no way to initialize the displayed path (the
> problem is that the client want a default value, which must be display and
> if the client make sumbmit i must make trt with it)
> furthermore ,in the trt, i want the absolute path which i give as parameter
> to other function
> but in the formFile, i find only getFileName(), which gives only the name ,
> not the absolute path
> have you an idea how can i get the absolute path?
>
> Regards
> Elyes
>
>
>
>
> 2008/12/11 Robert Graf-Waczenski <rg...@lsoft.com>
>
>   
>> Hi,
>>
>> short answer: This is not possible. This restriction is not imposed by
>> Struts but is instead due to a restriction of the <input type="file"> html
>> tag, for which the value can not be prefilled or changed programmatically.
>> In our app we therefore have the pattern that when a file is currently
>> already uploaded, then we have a readonly display of the file name and other
>> statistics plus a link that reads "upload new file" (or something similar).
>> This link opens our upload page which the user can then use to upload the
>> file. Then the system goes back to the original page with the new file's
>> details.
>>
>> HTH,
>>
>> Robert
>>
>>
>> elyes sallem wrote:
>>
>>     
>>> Hello,
>>> in a form, a define a <html:file
>>> and i defined a form file as property
>>> i wanna initialise the path and display it in first access
>>> i have the value of the path by default
>>> i will initialise it in the default constructor of the actionForm
>>> but i don't know how affect a path to FormFile
>>> assume that the property is
>>> FormFile scopeFile
>>> and the default path is, c:\dev\scope.cvs
>>> how can i initialise scope to this path?
>>>
>>> Thanks in advance
>>> Elyes
>>>
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
>
>   


Re: initialise a form file

Posted by elyes sallem <el...@gmail.com>.
OK, thanks for your response
if i understood well, there is no way to initialize the displayed path (the
problem is that the client want a default value, which must be display and
if the client make sumbmit i must make trt with it)
furthermore ,in the trt, i want the absolute path which i give as parameter
to other function
but in the formFile, i find only getFileName(), which gives only the name ,
not the absolute path
have you an idea how can i get the absolute path?

Regards
Elyes




2008/12/11 Robert Graf-Waczenski <rg...@lsoft.com>

> Hi,
>
> short answer: This is not possible. This restriction is not imposed by
> Struts but is instead due to a restriction of the <input type="file"> html
> tag, for which the value can not be prefilled or changed programmatically.
> In our app we therefore have the pattern that when a file is currently
> already uploaded, then we have a readonly display of the file name and other
> statistics plus a link that reads "upload new file" (or something similar).
> This link opens our upload page which the user can then use to upload the
> file. Then the system goes back to the original page with the new file's
> details.
>
> HTH,
>
> Robert
>
>
> elyes sallem wrote:
>
>> Hello,
>> in a form, a define a <html:file
>> and i defined a form file as property
>> i wanna initialise the path and display it in first access
>> i have the value of the path by default
>> i will initialise it in the default constructor of the actionForm
>> but i don't know how affect a path to FormFile
>> assume that the property is
>> FormFile scopeFile
>> and the default path is, c:\dev\scope.cvs
>> how can i initialise scope to this path?
>>
>> Thanks in advance
>> Elyes
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Elyes.

Re: initialise a form file

Posted by Robert Graf-Waczenski <rg...@lsoft.com>.
Hi,

short answer: This is not possible. This restriction is not imposed by 
Struts but is instead due to a restriction of the <input type="file"> 
html tag, for which the value can not be prefilled or changed 
programmatically. In our app we therefore have the pattern that when a 
file is currently already uploaded, then we have a readonly display of 
the file name and other statistics plus a link that reads "upload new 
file" (or something similar). This link opens our upload page which the 
user can then use to upload the file. Then the system goes back to the 
original page with the new file's details.

HTH,

Robert

elyes sallem wrote:
> Hello,
> in a form, a define a <html:file
> and i defined a form file as property
> i wanna initialise the path and display it in first access
> i have the value of the path by default
> i will initialise it in the default constructor of the actionForm
> but i don't know how affect a path to FormFile
> assume that the property is
> FormFile scopeFile
> and the default path is, c:\dev\scope.cvs
> how can i initialise scope to this path?
>
> Thanks in advance
> Elyes
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: initialise a form file

Posted by Andras Balogh <an...@reea.net>.
Hi,

A HTML input of type file can't have a default value. This is a security 
issue.

BR,
Andras

elyes sallem wrote:
> Hello,
> in a form, a define a <html:file
> and i defined a form file as property
> i wanna initialise the path and display it in first access
> i have the value of the path by default
> i will initialise it in the default constructor of the actionForm
> but i don't know how affect a path to FormFile
> assume that the property is
> FormFile scopeFile
> and the default path is, c:\dev\scope.cvs
> how can i initialise scope to this path?
>
> Thanks in advance
> Elyes
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org