Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-24 Thread Jonas Sicking

Adele Peterson wrote:

Hi all,

I'm looking at the Web Forms 2 specification for the multi-file upload 
control that uses the min/max attributes.  When multiple files are 
selected, its unclear what the value attribute should contain.  It could 
contain just the first filename, or a comma separated list of all of the 
filenames.  I think it will be useful though to add something about this 
in the specification for consistency.


Firefox 3 exposes an API that would let you get all filenames if 
multiple files were selected. The .files property returns a (live) list 
of file objects, each object has the following API:


interface DOMFile
{
  readonly attribute DOMString fileName;
  readonly attribute unsigned long long fileSize;

  DOMString getAsText(in DOMString encoding);
  DOMString getAsDataURL();
  DOMString getAsBinary();
};

This of course doesn't answer the question of what to return for .value. 
I would say return the first filename. Trying to encode all filenames in 
a single string is just going to be more complicated than using the 
above API, and returning an array is complicated API wise, and also 
seems more complicated for users than using the above API.


/ Jonas


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-22 Thread Lachlan Hunt

Michael A. Puls II wrote:

Anyway, the use case for .value is:

...
pFile to attach: p
pinput type=file
onchange=document.getElementsByTagName('p')[0].innerHTML +=
this.value;/p
...


How is that a use case?  Please explain why outputting the value of the 
control in an adjacent paragraph is useful at all and why authors would 
do it.  The value is visible in the control itself, so that seems 
unnecessary.


--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-22 Thread Michael A. Puls II
On 6/22/08, Lachlan Hunt [EMAIL PROTECTED] wrote:
 Michael A. Puls II wrote:

  Anyway, the use case for .value is:
 
  ...
 pFile to attach: p
 pinput type=file
  onchange=document.getElementsByTagName('p')[0].innerHTML
 +=
  this.value;/p
  ...
 

  How is that a use case?  Please explain why outputting the value of the
 control in an adjacent paragraph is useful at all and why authors would do
 it.  The value is visible in the control itself, so that seems unnecessary.

The file is visible in the control itself, but:

If the control is not long enough, you might not see the filename
unless you scroll in the field or the script resizes based on a
multiple of the length of .value. Even then, the path might be
considered noise.

An author might provide the filenames in a more friendly and readable way.

As another example, imagine you have input type=file and onchange,
it adds a filename to a SELECT element and resizes the element.

Then, the select has an onchange listener itself. When you select a
different file in the SELECT, you can make something happen.

For example, you can browse to .wav files and add them to a select
playlist. Then, you can select each of the filenames to have them play
with Audio() for example. Attached is a super basic example of that.

Instead of Audio(), you might load theora videos and play them with
the VideoLan plugin or load wmv files and play them with WMP.

-- 
Michael





Select a file in the playlist to play it
Add a .wav file to the playlist: 



Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-20 Thread Lachlan Hunt

Adele Peterson wrote:
I'm looking at the Web Forms 2 specification for the multi-file 
upload control that uses the min/max attributes.  When multiple files 
are selected, its unclear what the value attribute should contain.


Assuming you're referring to the value DOM attribute, not the value= 
content attribute, It seems to be unclear what the value should contain 
even when there's only a single file selected.


I did some testing to see what each returned.  All tests use this markup 
to obtain the value, using the Live DOM Viewer:


!DOCTYPE html
input type=file id=test size=100
input type=button onclick=w(document.getElementById('test').value); 
value=Read Value...


http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0D%0A%3Cinput%20type%3D%22file%22%20id%3D%22test%22%20size%3D100%3E%0D%0A%3Cinput%20type%3Dbutton%20onclick%3D%22w(document.getElementById('test').value)%3B%22%20value%3D%22Read%20Value...%22%3E

In each one, I selected a file named test.txt from within my home or My 
Documents directory.  These are the vaules returned in each browser:


Windows browsers:
IE 8: test.txt
IE 7 mode:test.txt
Firefox 2:D:\My Documents\test.txt
Firefox 3:test.txt
Opera 9.5:C:\fake_path\test.txt
Safari 3.1.1: D:\My Documents\test.txt

Mac browsers:
Firefox 3:test.txt
Opera 9.5:C:\fake_path\test.txt
Safari 4 (Developer Preview): /Users/lachlanhunt/test.txt

It could contain just the first filename, or a comma separated list 
of all of the filenames.  I think it will be useful though to add 
something about this in the specification for consistency.


Opera 9.5 supports multiple file selection when a max= attribute is 
set to a value greater than 1.  It currently only returns the fake path 
of the first file, as shown above.  However, the control displays to the 
user the real paths of all files selected as quoted strings separated by 
semi-colons. e.g.


/Users/lachlanhunt/test.txt;/Users/lachlanhunt/other.txt

Since Both Firefox 3 and IE 8 only return the file name, and Opera 9.5 
refuses to return the real path anyway, maybe we should define that when 
there's only a single file selected, it returns just the file name. When 
there are multiple files selected, would a string containing the file 
names, each surrounded by quotes and separated by semi-colons work?


e.g. test.txt;other.txt

There's a small problem with that too, because we would need a way to 
handle file names that contained quote marks, which is possible on Mac 
and Linux, but not on Windows.


But it really depends what use cases we need to address.  Do authors 
ever actually obtain the file name using JavaScript for anything?  If 
so, what for?  With multiple file selection, is it likely they would 
want to inspect each individual file name for anything, in which case, 
should we find a way to make it easier to obtain individual file names?


--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-20 Thread João Eiras
Hi

 There's a small problem with that too, because we would need a way to handle 
 file names
 that contained quote marks, which is possible on Mac and Linux, but not on 
 Windows.

Not only that, but in unix flavours, paths are separated with : while
in windows they're separated with ;
In *nix special char are escaped with \ while in windows \ separates
directories in paths.
So IMO, it won't be possible to com up with a solution that is cross
platform without making up something completly new.
I'd suggest for HTMLInputElement to have a .files or .paths property
which would be an array of all the files choosen, names only.


On Fri, Jun 20, 2008 at 2:44 PM, Lachlan Hunt [EMAIL PROTECTED] wrote:
 Adele Peterson wrote:

 I'm looking at the Web Forms 2 specification for the multi-file upload
 control that uses the min/max attributes.  When multiple files are selected,
 its unclear what the value attribute should contain.

 Assuming you're referring to the value DOM attribute, not the value=
 content attribute, It seems to be unclear what the value should contain even
 when there's only a single file selected.

 I did some testing to see what each returned.  All tests use this markup to
 obtain the value, using the Live DOM Viewer:

 !DOCTYPE html
 input type=file id=test size=100
 input type=button onclick=w(document.getElementById('test').value);
 value=Read Value...

 http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0D%0A%3Cinput%20type%3D%22file%22%20id%3D%22test%22%20size%3D100%3E%0D%0A%3Cinput%20type%3Dbutton%20onclick%3D%22w(document.getElementById('test').value)%3B%22%20value%3D%22Read%20Value...%22%3E

 In each one, I selected a file named test.txt from within my home or My
 Documents directory.  These are the vaules returned in each browser:

 Windows browsers:
 IE 8: test.txt
 IE 7 mode:test.txt
 Firefox 2:D:\My Documents\test.txt
 Firefox 3:test.txt
 Opera 9.5:C:\fake_path\test.txt
 Safari 3.1.1: D:\My Documents\test.txt

 Mac browsers:
 Firefox 3:test.txt
 Opera 9.5:C:\fake_path\test.txt
 Safari 4 (Developer Preview): /Users/lachlanhunt/test.txt

 It could contain just the first filename, or a comma separated list of all
 of the filenames.  I think it will be useful though to add something about
 this in the specification for consistency.

 Opera 9.5 supports multiple file selection when a max= attribute is set to
 a value greater than 1.  It currently only returns the fake path of the
 first file, as shown above.  However, the control displays to the user the
 real paths of all files selected as quoted strings separated by semi-colons.
 e.g.

 /Users/lachlanhunt/test.txt;/Users/lachlanhunt/other.txt

 Since Both Firefox 3 and IE 8 only return the file name, and Opera 9.5
 refuses to return the real path anyway, maybe we should define that when
 there's only a single file selected, it returns just the file name. When
 there are multiple files selected, would a string containing the file names,
 each surrounded by quotes and separated by semi-colons work?

 e.g. test.txt;other.txt

 There's a small problem with that too, because we would need a way to handle
 file names that contained quote marks, which is possible on Mac and Linux,
 but not on Windows.

 But it really depends what use cases we need to address.  Do authors ever
 actually obtain the file name using JavaScript for anything?  If so, what
 for?  With multiple file selection, is it likely they would want to inspect
 each individual file name for anything, in which case, should we find a way
 to make it easier to obtain individual file names?

 --
 Lachlan Hunt - Opera Software
 http://lachy.id.au/
 http://www.opera.com/



Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-20 Thread Michael A. Puls II
On 6/20/08, João Eiras [EMAIL PROTECTED] wrote:
 Hi


   There's a small problem with that too, because we would need a way to 
 handle file names
   that contained quote marks, which is possible on Mac and Linux, but not on 
 Windows.


 Not only that, but in unix flavours, paths are separated with : while
  in windows they're separated with ;
  In *nix special char are escaped with \ while in windows \ separates
  directories in paths.
  So IMO, it won't be possible to com up with a solution that is cross
  platform without making up something completly new.
  I'd suggest for HTMLInputElement to have a .files or .paths property
  which would be an array of all the files choosen, names only.


I like the idea of .files returning an array of just filenames. Great idea!

But, if .files is implemented, what should .value return then? Always
just the first filename? A separated list of platform-dependent
filenames with a separator that makes sense for separating filenames
on that platform? Nothing?

On a side, I'd like .paths to return a list of file URIs (when I allow
it, like for local pages or specific sites).  Be nice for building a
playlist for scripting media player type plugins or even Audio and
Video. That way, you could choose a bunch of files in a different
directory than the page and have the paths load in a playlist. (Or,
even use a script to convert the file URI to a platform path if the
plugin doesn't understand file URIs). Of course, I guess that'd have
to be a browser-specific thing and .vendor_paths.

Anyway, .files returning an array would be a lot better than trying to
parse some platform-specific separated list string that .value might
return.

-- 
Michael


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-20 Thread Lachlan Hunt

João Eiras wrote:

I'd suggest for HTMLInputElement to have a .files or .paths property
which would be an array of all the files choosen, names only.


Whether or not it's worth doing that really depends what use cases we're 
trying to address.  The initial post in this thread was just about 
defining what .value returns for file controls, which needs to be 
defined anyway and is what this thread should really focus on.


I don't think we should jump to the conclusion that we really need to 
provide an array of individual file names without defining why that's 
even useful for authors, especially when doing so doesn't actually 
address the original problem that was raised.


--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-20 Thread Thomas Broyer
On Fri, Jun 20, 2008 at 3:44 PM, Lachlan Hunt wrote:

 Windows browsers:
 IE 8: test.txt
 IE 7 mode:test.txt

For the record, real IE7 (on Vista) says the full path.

-- 
Thomas Broyer


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-20 Thread Frode Børli
Why can't .value returnere an array? just the first filename seems
silly. I would expect an array.

On 6/20/08, Thomas Broyer [EMAIL PROTECTED] wrote:
 On Fri, Jun 20, 2008 at 3:44 PM, Lachlan Hunt wrote:

 Windows browsers:
 IE 8: test.txt
 IE 7 mode:test.txt

 For the record, real IE7 (on Vista) says the full path.

 --
 Thomas Broyer



-- 
Best regards / Med vennlig hilsen
Frode Børli
Seria.no

Mobile:
+47 406 16 637
Company:
+47 216 90 000
Fax:
+47 216 91 000


Think about the environment. Do not print this e-mail unless you really need to.

Tenk miljø. Ikke skriv ut denne e-posten dersom det ikke er nødvendig.


[whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-19 Thread Adele Peterson

Hi all,

I'm looking at the Web Forms 2 specification for the multi-file upload  
control that uses the min/max attributes.  When multiple files are  
selected, its unclear what the value attribute should contain.  It  
could contain just the first filename, or a comma separated list of  
all of the filenames.  I think it will be useful though to add  
something about this in the specification for consistency.


Thanks,
Adele


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-19 Thread Frode Børli
I think it should be a select box containing each file name and
perhaps an icon, and when you select a file - it asks you if you want
to remove the file from the upload queue.

Frode

2008/6/19 Adele Peterson [EMAIL PROTECTED]:
 Hi all,

 I'm looking at the Web Forms 2 specification for the multi-file upload
 control that uses the min/max attributes.  When multiple files are selected,
 its unclear what the value attribute should contain.  It could contain just
 the first filename, or a comma separated list of all of the filenames.  I
 think it will be useful though to add something about this in the
 specification for consistency.

 Thanks,
Adele




-- 
Best regards / Med vennlig hilsen
Frode Børli
Seria.no

Mobile:
+47 406 16 637
Company:
+47 216 90 000
Fax:
+47 216 91 000


Think about the environment. Do not print this e-mail unless you really need to.

Tenk miljø. Ikke skriv ut denne e-posten dersom det ikke er nødvendig.


Re: [whatwg] What should the value attribute be for multi-file upload controls in WF2?

2008-06-19 Thread Frode Børli
Sorry for misunderstanding. Ofcourse it is up to the user agent to
decide the appearance. If the value attribute should be accessible
from script, then I would wish it was an array when accessed from
script. If it must be a string, then I think it the control itself
should contain multiple input type=file elements, each with a single
value - accessible trough DOM.

Separating by comma is not good enough, as file names can contain comma.

Frode

2008/6/20 Adele Peterson [EMAIL PROTECTED]:
 That's a suggestion for the design of the control, but I was asking
 specifically about the value attribute, which can be accessed from script as
 a string.

 - Adele

 On Jun 19, 2008, at 2:56 PM, Frode Børli wrote:

 I think it should be a select box containing each file name and
 perhaps an icon, and when you select a file - it asks you if you want
 to remove the file from the upload queue.

 Frode

 2008/6/19 Adele Peterson [EMAIL PROTECTED]:

 Hi all,

 I'm looking at the Web Forms 2 specification for the multi-file upload
 control that uses the min/max attributes.  When multiple files are
 selected,
 its unclear what the value attribute should contain.  It could contain
 just
 the first filename, or a comma separated list of all of the filenames.  I
 think it will be useful though to add something about this in the
 specification for consistency.

 Thanks,
  Adele




 --
 Best regards / Med vennlig hilsen
 Frode Børli
 Seria.no

 Mobile:
 +47 406 16 637
 Company:
 +47 216 90 000
 Fax:
 +47 216 91 000


 Think about the environment. Do not print this e-mail unless you really
 need to.

 Tenk miljø. Ikke skriv ut denne e-posten dersom det ikke er nødvendig.





-- 
Best regards / Med vennlig hilsen
Frode Børli
Seria.no

Mobile:
+47 406 16 637
Company:
+47 216 90 000
Fax:
+47 216 91 000


Think about the environment. Do not print this e-mail unless you really need to.

Tenk miljø. Ikke skriv ut denne e-posten dersom det ikke er nødvendig.