<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Browser Inconsistencies: File Inputs</title>
	<atom:link href="http://gordon-myers.com/?feed=rss2&#038;p=170" rel="self" type="application/rss+xml" />
	<link>http://gordon-myers.com/?p=170</link>
	<description>Now available in the freezer section from your local grocer.</description>
	<lastBuildDate>Wed, 05 May 2010 22:24:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Christopher Blizzard</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8809</link>
		<dc:creator>Christopher Blizzard</dc:creator>
		<pubDate>Tue, 16 Dec 2008 18:54:03 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8809</guid>
		<description>Here&#039;s some more on uploading from a file input from Jonas Sicking.  He says that you should be able to do something like this:


file = input.files[0];
xhr = new XMLHttpRequest;
xhr.open(&quot;POST&quot;, &quot;hi.cgi&quot;);
xhr.onload = ...;
xhr.sendAsBinary(file.getAsBinary());


With the URL in my previous comment you should be able to get progress events as well.</description>
		<content:encoded><![CDATA[<p>Here's some more on uploading from a file input from Jonas Sicking.  He says that you should be able to do something like this:</p>
<p>file = input.files[0];<br />
xhr = new XMLHttpRequest;<br />
xhr.open("POST", "hi.cgi");<br />
xhr.onload = ...;<br />
xhr.sendAsBinary(file.getAsBinary());</p>
<p>With the URL in my previous comment you should be able to get progress events as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gordon</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8788</link>
		<dc:creator>Gordon</dc:creator>
		<pubDate>Tue, 16 Dec 2008 03:28:28 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8788</guid>
		<description>Chris,

Your reply was a nice surprise! I wasn&#039;t expecting to get anything back from anyone official! I just have two things left to say. First, you say you haven&#039;t come up with any UI for clearing the file yet--but why not just do what Chrome is doing? That is, if you click &quot;Browse...&quot;, and then press Cancel, have it clear out the file automatically. It&#039;s maybe not the most intuitive UI, but at least it&#039;s something (until you come up with something better). I didn&#039;t think to try clearing the value through JavaScript (that&#039;s good to know), but that&#039;s still more of a solution geared toward developers and not toward users. The other thing I have left to say is about CSS. I can understand that you&#039;d be a bit weary to just do whatever you wanted in place of nonexistent standards, but some of the simpler attributes (e.g. height/width), seem pretty straightforward (then again I&#039;ve never developed a browser!).

And lastly, if you do manage to find the documentation for uploading data from a file input through an XMLHttpRequest, that would be fantastic. Thanks much!</description>
		<content:encoded><![CDATA[<p>Chris,</p>
<p>Your reply was a nice surprise! I wasn't expecting to get anything back from anyone official! I just have two things left to say. First, you say you haven't come up with any UI for clearing the file yet--but why not just do what Chrome is doing? That is, if you click "Browse...", and then press Cancel, have it clear out the file automatically. It's maybe not the most intuitive UI, but at least it's something (until you come up with something better). I didn't think to try clearing the value through JavaScript (that's good to know), but that's still more of a solution geared toward developers and not toward users. The other thing I have left to say is about CSS. I can understand that you'd be a bit weary to just do whatever you wanted in place of nonexistent standards, but some of the simpler attributes (e.g. height/width), seem pretty straightforward (then again I've never developed a browser!).</p>
<p>And lastly, if you do manage to find the documentation for uploading data from a file input through an XMLHttpRequest, that would be fantastic. Thanks much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Blizzard</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8785</link>
		<dc:creator>Christopher Blizzard</dc:creator>
		<pubDate>Tue, 16 Dec 2008 01:36:15 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8785</guid>
		<description>Hi, Gordon.  Thanks for all your comments.  There&#039;s a lot of useful stuff in here.  We&#039;ve been talking about a lot of these issues at Mozilla.  But I thought that responding to some of your comments might help to put things in perspective.

First, I think that a lot of what you are running into is work that we&#039;ve explicitly done to try and protect users when they are browsing the web.  We have two sets of audiences, users and developers, and sometimes they tend to conflict with each other.

In the case of file upload, there are a few important things that I&#039;d like to respond to:

1. Text Box

This is included because we want the user to know what file they have selected.  It&#039;s pretty easy to accidentally pick the wrong file and we want the user to have the chance to pick up on that mistake.  We might change it in the future to not look like a text box.  The only reason that it looks like one right now is largely a function of history.  It was easier for us to make the text box read only than it was to try and change it to something else.  Especially since we didn&#039;t really know what that something else might look like.  This might change in the future.

2. Typing in Manually

It turns out that it was too easy to trick people into typing in a dangerous filename or cutting and pasting something that they shouldn&#039;t.  One of our developers has a good story about an interesting attack that someone came up with: by allowing key press events and switching focus back and forth between a captcha and the file control they were able to take the text in the captcha which said &quot;house / extra cat / passport w#d&quot; and turn it into /etc/passwd in the file control, and the user would upload their password file.  They spent a lot of time trying to come up with specific ways to defeat attacks as they came up, but the attacks kept getting more and more creative.  So they just removed the functionality - it was just too dangerous.  We&#039;re looking at ways to be able to type in filenames, but it will probably happen outside of the web page itself - possibly in the file picker.

3. Clear File

The only reason this isn&#039;t included is because we haven&#039;t come up with a UI for it.  Note that you can clear it in script if you want by setting .value=&quot;&quot; from another button.

4. .value Returns Full Path: Once again, this is about protecting users.  Specifically preventing information about directory structure from being leaked to web sites.  On a huge number of machines the account name for the user is included in the full path name.  And if you have the username that&#039;s half of what&#039;s required for a username + password attack.

One of our developers points out that sometimes there are other things you might not have wanted to have uploaded.  For example &quot;/home/sicking/my boss is stupid/report.doc&quot; - I wouldn&#039;t want that uploaded.

5. CSS Rules.

The only reason why this doesn&#039;t work is because we haven&#039;t figured out all of the interactions, they aren&#039;t defined in the standards and we&#039;re somewhat reluctant to go out and create that entirely on our own.  And you can apply some CSS rules to the file control - just not all of them.

6. Upload Progress.

You can actually get update information as an xmlhttprequest is completing.  There&#039;s some information here:

https://developer.mozilla.org/En/Using_XMLHttpRequest#Monitoring_progress

And I&#039;m told that you&#039;re able to upload data that was selected via the file upload control, but I&#039;m embarrassed to admit that I can&#039;t find the document on it.  I&#039;ll keep looking for it.

Thanks for your comments, Gordon.  It&#039;s important feedback.</description>
		<content:encoded><![CDATA[<p>Hi, Gordon.  Thanks for all your comments.  There's a lot of useful stuff in here.  We've been talking about a lot of these issues at Mozilla.  But I thought that responding to some of your comments might help to put things in perspective.</p>
<p>First, I think that a lot of what you are running into is work that we've explicitly done to try and protect users when they are browsing the web.  We have two sets of audiences, users and developers, and sometimes they tend to conflict with each other.</p>
<p>In the case of file upload, there are a few important things that I'd like to respond to:</p>
<p>1. Text Box</p>
<p>This is included because we want the user to know what file they have selected.  It's pretty easy to accidentally pick the wrong file and we want the user to have the chance to pick up on that mistake.  We might change it in the future to not look like a text box.  The only reason that it looks like one right now is largely a function of history.  It was easier for us to make the text box read only than it was to try and change it to something else.  Especially since we didn't really know what that something else might look like.  This might change in the future.</p>
<p>2. Typing in Manually</p>
<p>It turns out that it was too easy to trick people into typing in a dangerous filename or cutting and pasting something that they shouldn't.  One of our developers has a good story about an interesting attack that someone came up with: by allowing key press events and switching focus back and forth between a captcha and the file control they were able to take the text in the captcha which said "house / extra cat / passport w#d" and turn it into /etc/passwd in the file control, and the user would upload their password file.  They spent a lot of time trying to come up with specific ways to defeat attacks as they came up, but the attacks kept getting more and more creative.  So they just removed the functionality -- it was just too dangerous.  We're looking at ways to be able to type in filenames, but it will probably happen outside of the web page itself -- possibly in the file picker.</p>
<p>3. Clear File</p>
<p>The only reason this isn't included is because we haven't come up with a UI for it.  Note that you can clear it in script if you want by setting .value="" from another button.</p>
<p>4. .value Returns Full Path: Once again, this is about protecting users.  Specifically preventing information about directory structure from being leaked to web sites.  On a huge number of machines the account name for the user is included in the full path name.  And if you have the username that's half of what's required for a username + password attack.</p>
<p>One of our developers points out that sometimes there are other things you might not have wanted to have uploaded.  For example "/home/sicking/my boss is stupid/report.doc" -- I wouldn't want that uploaded.</p>
<p>5. CSS Rules.</p>
<p>The only reason why this doesn't work is because we haven't figured out all of the interactions, they aren't defined in the standards and we're somewhat reluctant to go out and create that entirely on our own.  And you can apply some CSS rules to the file control -- just not all of them.</p>
<p>6. Upload Progress.</p>
<p>You can actually get update information as an xmlhttprequest is completing.  There's some information here:</p>
<p><a href="https://developer.mozilla.org/En/Using_XMLHttpRequest#Monitoring_progress" rel="nofollow">https://developer.mozilla.org/En/Using_XMLHttpRequest#Monitoring_progress</a></p>
<p>And I'm told that you're able to upload data that was selected via the file upload control, but I'm embarrassed to admit that I can't find the document on it.  I'll keep looking for it.</p>
<p>Thanks for your comments, Gordon.  It's important feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alvaro</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8769</link>
		<dc:creator>Alvaro</dc:creator>
		<pubDate>Mon, 15 Dec 2008 14:29:17 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8769</guid>
		<description>You&#039;re not mentioning another difference in file input behavior: Drag&amp;Drop. Some browsers (AFAIK Webkit, Opera?, and FF with the DragDropUpload extension) allow you to drag a file from the file manager into the box so that the file path is quickly written into it. Very handy! no more browsing around dozens of folders (because it always starts from the root).

This feature should be in all browsers.</description>
		<content:encoded><![CDATA[<p>You're not mentioning another difference in file input behavior: Drag&amp;Drop. Some browsers (AFAIK Webkit, Opera?, and FF with the DragDropUpload extension) allow you to drag a file from the file manager into the box so that the file path is quickly written into it. Very handy! no more browsing around dozens of folders (because it always starts from the root).</p>
<p>This feature should be in all browsers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gordon</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8731</link>
		<dc:creator>Gordon</dc:creator>
		<pubDate>Sun, 14 Dec 2008 15:39:07 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8731</guid>
		<description>I think it&#039;s a little unfair to assume that there are no cases where having the full file path could possibly be useful. What if you want to keep the standard file inputs on the page for compatibility issues, but also have a Java applet running that receives the file path from JavaScript and then does some (optional) preprocessing on the file? I don&#039;t think that&#039;s too big of a stretch to envision.</description>
		<content:encoded><![CDATA[<p>I think it's a little unfair to assume that there are no cases where having the full file path could possibly be useful. What if you want to keep the standard file inputs on the page for compatibility issues, but also have a Java applet running that receives the file path from JavaScript and then does some (optional) preprocessing on the file? I don't think that's too big of a stretch to envision.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse McNelis</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8727</link>
		<dc:creator>Jesse McNelis</dc:creator>
		<pubDate>Sun, 14 Dec 2008 12:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8727</guid>
		<description>The main reason for not providing the full path is that it&#039;s not actually important or useful to the Javascript in the webpage or the remote webserver the file is being sent to, so there is not reason to provide it.

But there are plenty of reasons not to provide it, the user may give away important information with out realising it: usernames, actual full names, company names, directory names that contain secret informations(eg. new company product names) etc.

It&#039;s obvious to the user that they are sending a file, and that the file name will also be send, but it&#039;s not obvious that the directory structure would be sent.

eg. A girl recently uploaded pictures to me through my website, and in the process gave away her Mother&#039;s full name, which was in the directory structure.

- Jesse McNelis</description>
		<content:encoded><![CDATA[<p>The main reason for not providing the full path is that it's not actually important or useful to the Javascript in the webpage or the remote webserver the file is being sent to, so there is not reason to provide it.</p>
<p>But there are plenty of reasons not to provide it, the user may give away important information with out realising it: usernames, actual full names, company names, directory names that contain secret informations(eg. new company product names) etc.</p>
<p>It's obvious to the user that they are sending a file, and that the file name will also be send, but it's not obvious that the directory structure would be sent.</p>
<p>eg. A girl recently uploaded pictures to me through my website, and in the process gave away her Mother's full name, which was in the directory structure.</p>
<p>- Jesse McNelis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: User</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8719</link>
		<dc:creator>User</dc:creator>
		<pubDate>Sun, 14 Dec 2008 07:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8719</guid>
		<description>One reason that someone may not want full paths is that system usernames get leaked out to the site.  Not a very good reason, but just a thought.</description>
		<content:encoded><![CDATA[<p>One reason that someone may not want full paths is that system usernames get leaked out to the site.  Not a very good reason, but just a thought.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gordon</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8717</link>
		<dc:creator>Gordon</dc:creator>
		<pubDate>Sun, 14 Dec 2008 06:21:35 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8717</guid>
		<description>Thanks for mentioning that. I didn&#039;t bring that up in this post, but I was indeed aware about these style &quot;hacks&quot; done with superimposed divs and 0% opacity on the input. But overall it&#039;s still disappointing that our only real solutions at this point, as developers, are &quot;hacks.&quot; File inputs are such a core feature of browsers that you&#039;d think they&#039;d offer more features and be more standardized in general.</description>
		<content:encoded><![CDATA[<p>Thanks for mentioning that. I didn't bring that up in this post, but I was indeed aware about these style "hacks" done with superimposed divs and 0% opacity on the input. But overall it's still disappointing that our only real solutions at this point, as developers, are "hacks." File inputs are such a core feature of browsers that you'd think they'd offer more features and be more standardized in general.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niels</title>
		<link>http://gordon-myers.com/?p=170&#038;cpage=1#comment-8715</link>
		<dc:creator>Niels</dc:creator>
		<pubDate>Sun, 14 Dec 2008 05:40:21 +0000</pubDate>
		<guid isPermaLink="false">http://gordon-myers.com/?p=170#comment-8715</guid>
		<description>IE8, or at least, the beta version I have seen a while back restricts the value given to JavaScript to just the filename too..  Great fun. 

Styling the Fileinput is somewhat possible with a little scripthack that makes it invisible, overlays it with a custom image and then moves the input field around on mouseover so your button is always under the pointer when a mouseclick occurs..  see http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom for details..</description>
		<content:encoded><![CDATA[<p>IE8, or at least, the beta version I have seen a while back restricts the value given to JavaScript to just the filename too..  Great fun. </p>
<p>Styling the Fileinput is somewhat possible with a little scripthack that makes it invisible, overlays it with a custom image and then moves the input field around on mouseover so your button is always under the pointer when a mouseclick occurs..  see <a href="http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom" rel="nofollow">http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom</a> for details..</p>
]]></content:encoded>
	</item>
</channel>
</rss>
