473,418 Members | 2,069 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,418 software developers and data experts.

cross browser multipart form handling

So, one of the limitations of multipart-form handling is that when an <input
type="file" ..> tag is used it will bring up a window which allows a user to
select a file for upload but won't allow the user to select multiple files.
As you may know, the tag produces a text input field with an adjacent button
for selecting a file from the local file system.

As I would like to be able to allow the user to upload an arbitrary number
of files and process them as a batch on the server side I came up with the
following solution:

I've added an onClick event to the input element like this:

<div id="files"><input class="textsmall" type="file" name="file-0" id="file-
0" size="70" value="Browse" onClick="FormUtil.addFile(this);"/></div>

The FormUtil.addFile() function creates a new input element and appends it
as a child of the element with an id of "files".

The first thing I noticed is that clicking in the text box initiates the
onClick event (not just clicking on the button as I would have hoped). To
handle this I can check the value. If it is zero length, I send an alert
message indicating to select the Browse button. Once the browse window pops
up and a file is select, the new input element is created and onClick
attribute is removed from the element just clicked (this allows changing
that input tag without creating a new element).

This works quite well in Firefox. However, it appears that the order of the
event handling is different for IE. In Firefox it appears that the browse
window is displayed first, and once the file has been selected, the onClick
event fires. In IE, it appears that the onClick event fires first and the
browse window isn't displayed until the event completes.

Does anyone have a cross browser solution?
Sep 2 '05 #1
4 2777
ASM
John Fereira wrote:
Does anyone have a cross browser solution?


onchange ?

never I though to use onclick for that filer
(with my IE needs to click overside the field)

--
Stephane Moriaux et son [moins] vieux Mac
Sep 2 '05 #2
John Fereira wrote:
So, one of the limitations of multipart-form handling is that when an <input
type="file" ..> tag is used it will bring up a window which allows a user to
select a file for upload but won't allow the user to select multiple files.
As you may know, the tag produces a text input field with an adjacent button
for selecting a file from the local file system.
On some browsers only the button is shown until a file is selected,
don't expect that the text field is always visible from the start.

As I would like to be able to allow the user to upload an arbitrary number
of files and process them as a batch on the server side I came up with the
following solution:

I've added an onClick event to the input element like this:

<div id="files"><input class="textsmall" type="file" name="file-0" id="file-
0" size="70" value="Browse" onClick="FormUtil.addFile(this);"/></div>

The FormUtil.addFile() function creates a new input element and appends it
as a child of the element with an id of "files".

The first thing I noticed is that clicking in the text box initiates the
onClick event (not just clicking on the button as I would have hoped). To
The element is both the field and the button, so I guess a click on
either is a click on the element. There is no way to code an on-click
for just the text area or just the button.
handle this I can check the value. If it is zero length, I send an alert
message indicating to select the Browse button. Once the browse window pops
That would annoy the heck out of me, why not just do nothing?
up and a file is select, the new input element is created and onClick
attribute is removed from the element just clicked (this allows changing
that input tag without creating a new element).
But means that the behaviour changes with no sign to the user that it
has. Again, potentially confusing and annoying.

This works quite well in Firefox. However, it appears that the order of the
event handling is different for IE. In Firefox it appears that the browse
window is displayed first, and once the file has been selected, the onClick
event fires. In IE, it appears that the onClick event fires first and the
browse window isn't displayed until the event completes.


I think you have a number of usability issues here that can be avoided
by using a separate button to create the extra input. When the button
is clicked, add another input.

You may want to add a 'delete' button too to get rid of extra inputs
that might be created in error - have fun with it! :-)

--
Rob
Sep 3 '05 #3
RobG <rg***@iinet.net.au> wrote in
news:43*********************@per-qv1-newsreader-01.iinet.net.au:
John Fereira wrote:
So, one of the limitations of multipart-form handling is that when an
<input type="file" ..> tag is used it will bring up a window which
allows a user to select a file for upload but won't allow the user to
select multiple files. As you may know, the tag produces a text input
field with an adjacent button for selecting a file from the local file
system.
On some browsers only the button is shown until a file is selected,
don't expect that the text field is always visible from the start.


In this case, the page is an administrative interface that will only be used
by a handful of people so I have some control over what browsers will be
used. Unfortunately a couple of those users are from a government agency
that is a bit MS shop so they'll be using IE. I've looked at it in opera it
appears there is some confusion as to what the value attribute means. On IE
and firefox setting the value dictates the text used on the button but on
opera it also uses that contents for the input box.

As I would like to be able to allow the user to upload an arbitrary
number of files and process them as a batch on the server side I came
up with the following solution:

I've added an onClick event to the input element like this:

<div id="files"><input class="textsmall" type="file" name="file-0"
id="file- 0" size="70" value="Browse"
onClick="FormUtil.addFile(this);"/></div>

The FormUtil.addFile() function creates a new input element and
appends it as a child of the element with an id of "files".

The first thing I noticed is that clicking in the text box initiates
the onClick event (not just clicking on the button as I would have
hoped). To
The element is both the field and the button, so I guess a click on
either is a click on the element. There is no way to code an on-click
for just the text area or just the button.
handle this I can check the value. If it is zero length, I send an
alert message indicating to select the Browse button. Once the browse
window pops


That would annoy the heck out of me, why not just do nothing?


I could do that. Since the same people will be using the page I imagine
that it will only take one click in the text box to get the message.
up and a file is select, the new input element is created and onClick
attribute is removed from the element just clicked (this allows
changing that input tag without creating a new element).
But means that the behaviour changes with no sign to the user that it
has. Again, potentially confusing and annoying.


Actually, the behavior does change. The contents of the adjacent text field
box changes. Again, since it's only going to be used by a few people an
explanation of the expected behavior would prevent any confusion. It might
not be totally intuitive but it doesn't have to be.

This works quite well in Firefox. However, it appears that the order
of the event handling is different for IE. In Firefox it appears that
the browse window is displayed first, and once the file has been
selected, the onClick event fires. In IE, it appears that the onClick
event fires first and the browse window isn't displayed until the
event completes.
I think you have a number of usability issues here that can be avoided
by using a separate button to create the extra input. When the button
is clicked, add another input.


I thought about doing that but it would require an extra click to add an
additional file.
You may want to add a 'delete' button too to get rid of extra inputs
that might be created in error - have fun with it! :-)


The server side will handle the form elements with empty text fields so a
delete isn't really necessary. There is also a Cancel button that will
remove all child elements of the "files" element then add one to start over.
Since the page will have limited and predictable usage (it will be used
about 2-3 times a day to upload 2-3 files at a time) I can play a bit with
the user interface without too much consideration for users running on old
browsers. For example, I may add some AJAX functionalit (using Direct Web
Remoting) that will do some filename validation before submitting the form.
After the files are uploaded they'll get renamed using a standard convention
based on some information in a backend database and the "release date"
provided by the users. The release date is selected using JSCalendar.
Sep 3 '05 #4
ASM <st*********************@wanadoo.fr.invalid> wrote in news:4318e1f1$0
$1************@news.wanadoo.fr:
John Fereira wrote:
Does anyone have a cross browser solution?
onchange ?


That just might work. I'll let you know.
never I though to use onclick for that filer
(with my IE needs to click overside the field)


I hadn't thouht to use onChange. The element is different from other form
elements in that it produces both a text field and a button but the events
seem to apply to both. An onClick would seem to apply to the button while
an onChange might be more appropriate for the text field.

Sep 3 '05 #5

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

Similar topics

7
by: Joe | last post by:
I have an upload file operation in the web application. UploadForm.asp is the form, and UploadAction.asp is the form processing. //UploadForm.asp <FORM NAME="InputForm"...
7
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem...
2
by: Questman | last post by:
Good afternoon, Does anyone have any code that implements, or approaches implementing, a cross-browser DHTML/JS solution to provide an Excel-like Grid on a web page - I'm trying to convert an...
4
by: pbd22 | last post by:
hi. could somebody tell me, when uploading a file, i know the form where the upload component is must have enctype=multipart/form-data but, is the same true for the form with the server code to...
0
by: shlim | last post by:
Currently I'm using VB.Net to perform a http/https multipart form post to a servlet. I'm able to perform the post using HttpWebrequest via GetRequestStream(). However, the servlet returned me with...
2
by: ashore | last post by:
Folks, lots of stuff around re "multipart/x-mixed-replace" , which isn't supported on MS browsers. But i understand that they DO support an alternative server-push approach. I've Googled...
3
by: jeremy.gehring | last post by:
Hey all, OK I'm not much of a PHP programmer; but needs must as they say. I have written AJAX file upload system that uses a PERL CGI script so that a PHP script can get the progress (nifty...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.