homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Browsers / Opera Browser Usage and Support
Forum Library, Charter, Moderator: open

Opera Browser Usage and Support Forum

Setting default value for file upload form
Not supported by IE and FF, only by Opera?

10+ Year Member

Msg#: 398 posted 9:02 pm on Dec 19, 2005 (gmt 0)

I want to fill in a default filename for a file upload form.

<input type="file" size="35" name="imgupload" value="a:\\image.jpg">

But it seems this is only supported by Opera and Opera ask for a confirmation. It doesn't work in IE or FF.

Is there anyway to go around this, e.g. using javascript? It is ok when the user has to click the filename before it is being filled-in in the input box.
So maybe I had to post this in the Javascript forum, but I'm hoping there is way to do it without using Javascript.

I want to use this for a form in which the user can type in or upload some HTML text and via a PHP script I want to scan the text for IMG tags so the user can easily upload the images after the HTML text has been uploaded.





WebmasterWorld Senior Member encyclo us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 398 posted 2:46 am on Dec 20, 2005 (gmt 0)

As you have seen, only Opera supports this. The HTML4 specifications [w3.org] suggest:

User agents may use the value of the value attribute as the initial file name.

But in reality it is pretty unworkable: there are two distinct problems, the first being security (hence the confirmation step in Opera, else confidential information could unwittingly be uploaded). The second problem is platform differences: I run Linux, so there is no a:\ path - you can't reliably second-guess a file's location.

You might want to check out Jukka Korpela's (as always) very comprehensive guide:



10+ Year Member

Msg#: 398 posted 7:51 am on Dec 20, 2005 (gmt 0)

Hi encyclo,

Thanks for your answer. I'm aware of possible security issues and the Linux 'problem', my idea was to ask the user for a default path to the images and prepend that for each filename.

I already did some testing with javascripting but I think it is almost impossible to do. What I did was the following:

<input id="fileinput" type="file" size="35" name="imgupload" value="a:\image.jpg">

<a href="#" onlick="fileinput.value='a:\image.jpg'; return false;">a:\image.jpg</a>

In this case the user can click the filename from a list extracted from the HTML test which will be inserted in the input box. But this also doesn't work. Another thing I tried was this:

<input id="fileinput" type="text" size="35" name="imgupload" value="a:\image.jpg">

<a href="#" onlick="fileinput.type='file'; return false;">a:\image.jpg</a>

This also doesn't work, as soon as the link is clicked, a 'Browse' button appears but also the box is emptied.

As for now I have no idea how to solve this apart from displaying a list of filenames and the user has to select and copy and paste them in the input box.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Browsers / Opera Browser Usage and Support
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved