473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Designing file upload in FF

Hi folks!

Could anybody explain why does the following code :

<form name="upload" method="post">
<input type="file" name="file_1" style="display:none" />
<input type="text" name="text_1" />
<a
href="javascript:document.forms['upload'].elements['file_1'].click();">
Open
</a>
</form>

open the file dialog for selecting a file for upload in the Internet
Explorer, whereas in the FF 2.0 does not?

Regards
Victor

Nov 24 '06 #1
7 1775
ASM
Victor a écrit :
Hi folks!

Could anybody explain why does the following code :
That doesn't work with my :
- Firefox 2
- Opera 9

Seems to work wih Safari 1.3.2

--
Stephane Moriaux and his (less) old Mac already out of date
Nov 24 '06 #2
Well, but what is the reason?

ASM schrieb:
Victor a écrit :
Hi folks!

Could anybody explain why does the following code :

That doesn't work with my :
- Firefox 2
- Opera 9

Seems to work wih Safari 1.3.2

--
Stephane Moriaux and his (less) old Mac already out of date
Nov 24 '06 #3
Victor said the following on 11/24/2006 4:58 PM:
Hi folks!

Could anybody explain why does the following code :

<form name="upload" method="post">
<input type="file" name="file_1" style="display:none" />
<input type="text" name="text_1" />
<a
href="javascript:document.forms['upload'].elements['file_1'].click();">
Open
</a>
</form>

open the file dialog for selecting a file for upload in the Internet
Explorer, whereas in the FF 2.0 does not?
Because FF doesn't support the programmatic clicking of a file input
element.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 25 '06 #4

Randy Webb wrote:
<a
href="javascript:document.forms['upload'].elements['file_1'].click();">
Because FF doesn't support the programmatic clicking of a file input
element.
This is true, but additionally, Firefox doesn't support the click()
method on any DOM object, at all. You have to roll your own:

function generateClick(element) {
var clickevent=document.createEvent("MouseEvents")
clickevent.initEvent("click", true, true)
element.dispatchEvent(myevent)
}

However, even this won't work on the File input element. As far as
scripting is concerned, it's basically read-only - you can't "make" it
do anything. Which is a good thing.

David

Nov 25 '06 #5
Well, this good idea may have a good intention at its origin. But
consider the following :

I am developing a project, where there no buttons at all - it was the
wish of my customer. There are many dozens of elements for interacting
with the user, all of them uniformly designed - but for the single
place where an ugly system button would appear, with different look on
every other machine. Even worse, the project is multilingual where the
user must have possibility to switch the language of the entire site -
but for an ugly button stubbornly displaying always the same caption in
the language of the particular operating system...

AFAIK, it is not possible to provide any style for this wayward button,
isn't it?

Thus, the basic idea may have been very good intended. Known however,
that the way to the hell is paved with good intentions.

Any good intended advice for my situation would be highly appreciated.

Victor

David Golightly schrieb:
Randy Webb wrote:
<a
href="javascript:document.forms['upload'].elements['file_1'].click();">
Because FF doesn't support the programmatic clicking of a file input
element.

This is true, but additionally, Firefox doesn't support the click()
method on any DOM object, at all. You have to roll your own:

function generateClick(element) {
var clickevent=document.createEvent("MouseEvents")
clickevent.initEvent("click", true, true)
element.dispatchEvent(myevent)
}

However, even this won't work on the File input element. As far as
scripting is concerned, it's basically read-only - you can't "make" it
do anything. Which is a good thing.

David
Nov 25 '06 #6

Victor wrote:
I am developing a project, where there no buttons at all - it was the
wish of my customer. There are many dozens of elements for interacting
with the user, all of them uniformly designed - but for the single
place where an ugly system button would appear, with different look on
every other machine. Even worse, the project is multilingual where the
user must have possibility to switch the language of the entire site -
but for an ugly button stubbornly displaying always the same caption in
the language of the particular operating system...

AFAIK, it is not possible to provide any style for this wayward button,
isn't it?
Well, there is this article by Peter-Paul Koch on a hack that allows
you to do custom file upload buttons. Maybe that'll give you what
you're looking for:

http://www.quirksmode.org/dom/inputfile.html

-David

Nov 25 '06 #7
David Golightly wrote:
Randy Webb wrote:
>><a
href="javascript:document.forms['upload'].elements['file_1'].click();">
>Because FF doesn't support the programmatic clicking of a file
input element.

This is true, but additionally, Firefox doesn't support the
click() method on any DOM object, at all.
<snip>

Firefox does support a - click - method on some elements. <IPUT
type="submit"elmenets spring to mind.

Richard.
Nov 26 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tihon | last post by:
Hello! I again need your help, just can't understand whats going on. Got this upload pictures form and it's having problem handling large files (~1.5 - 2 MB). Everything works fine if i just...
2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
2
by: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage()...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
6
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the...
7
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.