This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > April 2004 > Set initial value for an INPUT TYPE="file"?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Set initial value for an INPUT TYPE="file"?
sstringer

2004-04-21, 10:30 pm

Hi,

Is there a way to set an initial value for the file browser INPUT? When I set 'value="foo"' the input field is blank.

Thanks,
Steve
danilocelic

2004-04-21, 10:30 pm

sstringer wrote:

> Hi,
>
> Is there a way to set an initial value for the file browser INPUT? When I set 'value="foo"' the input field is blank.


No you can't do that. Reason being is that it is a security risk. Imagine
specifying a path to an important file (passwords, cookies, etc) and then
further imagine that the form is automatically submitted when you visit a page,
the site would now have that important file to play with as they like. Thats why
you cannot set it's value.

--
Enjoy,
Danilo Celic

| Extending Knowledge, Daily
| http://www.CommunityMX.com/

Those who aren't looking often have their eyes open widest.
Michael Fesser

2004-04-21, 10:30 pm

.oO(danilocelic)

>sstringer wrote:
>
>
>No you can't do that.


Depends.

>Reason being is that it is a security risk. Imagine
>specifying a path to an important file (passwords, cookies, etc) and then
>further imagine that the form is automatically submitted when you visit a page,
>the site would now have that important file to play with as they like. Thats why
>you cannot set it's value.


It's allowed by the spec:

"[control type] file
Creates a file select control. User agents may use the value of the
value attribute as the initial file name."

and some browsers support it (Opera and Lynx for example).

Micha
danilocelic

2004-04-21, 10:31 pm

Michael Fesser wrote:

> It's allowed by the spec:
>
> "[control type] file
> Creates a file select control. User agents may use the value of the
> value attribute as the initial file name."
>
> and some browsers support it (Opera and Lynx for example).



Thanks for the info, Micha, wasn't aware that.

I guess that I'll be making sure to not use those browsers, as that is
definitely a big security issue, if the form can be submitted automatically via
scripting.

--
Enjoy,
Danilo Celic

| Extending Knowledge, Daily
| http://www.CommunityMX.com/

Those who aren't looking often have their eyes open widest.
Gary White

2004-04-21, 10:31 pm

On Wed, 21 Apr 2004 17:46:58 +0000 (UTC), "sstringer"
<webforumsuser@macromedia.com> wrote:

>Is there a way to set an initial value for the file browser INPUT?
>When I set 'value="foo"' the input field is blank.



Not reliably. Opera may be the only browser that supports it.


Gary
Sponsored Links


Copyright 2003 - 2009 forum4designers.com  Software forum  Computer Hardware reviews