<?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: Firefox 4 &#8211; FormData and the new File.url object</title>
	<atom:link href="http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/feed/" rel="self" type="application/rss+xml" />
	<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/</link>
	<description>hacks.mozilla.org</description>
	<lastBuildDate>Fri, 10 Feb 2012 00:05:32 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Radek Tetík</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-376360</link>
		<dc:creator>Radek Tetík</dc:creator>
		<pubDate>Tue, 15 Feb 2011 13:04:28 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-376360</guid>
		<description>FormData is a great API. I have just implemented it and works well in FF4b11 and Chrome 10. Sadly it does not work in IE9.</description>
		<content:encoded><![CDATA[<p>FormData is a great API. I have just implemented it and works well in FF4b11 and Chrome 10. Sadly it does not work in IE9.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sol</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-269140</link>
		<dc:creator>Sol</dc:creator>
		<pubDate>Mon, 22 Nov 2010 08:02:18 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-269140</guid>
		<description>How exactly File.url work? I get undefined trying to get it.</description>
		<content:encoded><![CDATA[<p>How exactly File.url work? I get undefined trying to get it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michel</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-216090</link>
		<dc:creator>Michel</dc:creator>
		<pubDate>Wed, 27 Oct 2010 16:17:06 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-216090</guid>
		<description>Can  Anyone help me correctly do a preflight cors post in Fx 3.6 ? 
http://stackoverflow.com/questions/4034223/correct-way-to-do-cors-preflight-post-using-jquery
and will the same code work in Fx4?</description>
		<content:encoded><![CDATA[<p>Can  Anyone help me correctly do a preflight cors post in Fx 3.6 ?<br />
<a href="http://stackoverflow.com/questions/4034223/correct-way-to-do-cors-preflight-post-using-jquery" rel="nofollow">http://stackoverflow.com/questions/4034223/correct-way-to-do-cors-preflight-post-using-jquery</a><br />
and will the same code work in Fx4?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shiv Kumar</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-146384</link>
		<dc:creator>Shiv Kumar</dc:creator>
		<pubDate>Thu, 23 Sep 2010 06:09:24 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-146384</guid>
		<description>Answering my own question...

If you have a form field with an id of \fileToUpload\ and this field is an input element of type file. then

var myFile = document.getElementById(&#039;fileToUpload&#039;).Files[0];</description>
		<content:encoded><![CDATA[<p>Answering my own question&#8230;</p>
<p>If you have a form field with an id of \fileToUpload\ and this field is an input element of type file. then</p>
<p>var myFile = document.getElementById(&#8216;fileToUpload&#8217;).Files[0];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shiv Kumar</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-140112</link>
		<dc:creator>Shiv Kumar</dc:creator>
		<pubDate>Mon, 20 Sep 2010 05:08:58 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-140112</guid>
		<description>In your example:
var fd = new FormData();
fd.append(&quot;fileField&quot;, myFile);
var xhr = new XMLHttpRequest();
xhr.open(&quot;POST&quot;, &quot;file_handler.php&quot;);
xhr.send(fd);

what is myFile?
I&#039;ve tried document.getElementById(&quot;someformelement&quot;);

where someformelement is a 

But it is not send the file over to the server. It sends the additional form fields if appended to the FormData.

Sending the whole form using the next example works as expected.</description>
		<content:encoded><![CDATA[<p>In your example:<br />
var fd = new FormData();<br />
fd.append(&#8220;fileField&#8221;, myFile);<br />
var xhr = new XMLHttpRequest();<br />
xhr.open(&#8220;POST&#8221;, &#8220;file_handler.php&#8221;);<br />
xhr.send(fd);</p>
<p>what is myFile?<br />
I&#8217;ve tried document.getElementById(&#8220;someformelement&#8221;);</p>
<p>where someformelement is a </p>
<p>But it is not send the file over to the server. It sends the additional form fields if appended to the FormData.</p>
<p>Sending the whole form using the next example works as expected.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mawrya</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-119104</link>
		<dc:creator>mawrya</dc:creator>
		<pubDate>Mon, 30 Aug 2010 03:49:33 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-119104</guid>
		<description>Question: what if I want to add a web-accessible file to a form automatically via javascript? This example and others like it only cover user selected files - either via a form control or drag-and-drop. That makes sense for files on a user&#039;s computer as there is a security concern. What if I want to add files that are already and ONLY accessible from a web address? There is no way to do this with a drag and drop interface, nor a file picker interface. I want a script that gets the file at http://localhost/blah.xml and includes it with the other user selected files in the form. I would like to use the FormData.append() method to get the file into the form as it takes care of all the messy multipart/form-data encoding but it seems I need to first get the blah.xml file into a FileAPI file object. There doesn&#039;t appear to be any way to do this. Am I forced write javascript to manually read and multipart/form-data encode it and then attach it to the form somehow?

And thanks for the great posts!</description>
		<content:encoded><![CDATA[<p>Question: what if I want to add a web-accessible file to a form automatically via javascript? This example and others like it only cover user selected files &#8211; either via a form control or drag-and-drop. That makes sense for files on a user&#8217;s computer as there is a security concern. What if I want to add files that are already and ONLY accessible from a web address? There is no way to do this with a drag and drop interface, nor a file picker interface. I want a script that gets the file at <a href="http://localhost/blah.xml" rel="nofollow">http://localhost/blah.xml</a> and includes it with the other user selected files in the form. I would like to use the FormData.append() method to get the file into the form as it takes care of all the messy multipart/form-data encoding but it seems I need to first get the blah.xml file into a FileAPI file object. There doesn&#8217;t appear to be any way to do this. Am I forced write javascript to manually read and multipart/form-data encode it and then attach it to the form somehow?</p>
<p>And thanks for the great posts!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kensaku KOMATSU</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-116174</link>
		<dc:creator>Kensaku KOMATSU</dc:creator>
		<pubDate>Wed, 25 Aug 2010 06:39:02 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-116174</guid>
		<description>Thank you for supporting FormData!! It&#039;s make sense to me:)

However, under the condition that uploading files with FormData method to Cross-Origin Server, I found that preflight sequence occurred w/ FireFox4 beta (I tried beta3 and 4). In the CORS spec, if the method is &quot;POST&quot; and content-type is &quot;multipart/form-data&quot;, preflight sequence should not be occurred. So, I think this behavior does not corresponds to CORS spec.

P.S. Chrome 6 beta also supports FormData feature, and preflight sequence does not work with it.</description>
		<content:encoded><![CDATA[<p>Thank you for supporting FormData!! It&#8217;s make sense to me:)</p>
<p>However, under the condition that uploading files with FormData method to Cross-Origin Server, I found that preflight sequence occurred w/ FireFox4 beta (I tried beta3 and 4). In the CORS spec, if the method is &#8220;POST&#8221; and content-type is &#8220;multipart/form-data&#8221;, preflight sequence should not be occurred. So, I think this behavior does not corresponds to CORS spec.</p>
<p>P.S. Chrome 6 beta also supports FormData feature, and preflight sequence does not work with it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Werner Punz</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-104484</link>
		<dc:creator>Werner Punz</dc:creator>
		<pubDate>Sun, 01 Aug 2010 20:03:06 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-104484</guid>
		<description>Ok I gave this stuff a try, unfortunately (Firefox 4 Beta2) it still is buggy, while it is sending the form data as multipart request, it lacks some definitions most multipart decoders rely upon. The send generates the multipart request without divider definitions and without length definition.
Setting both manually also is not possible due to not being able to access the length of the generated submit content, and also due to the divider being generated at send time as well.

This seems like a bug to me, any idea where I can report this to?</description>
		<content:encoded><![CDATA[<p>Ok I gave this stuff a try, unfortunately (Firefox 4 Beta2) it still is buggy, while it is sending the form data as multipart request, it lacks some definitions most multipart decoders rely upon. The send generates the multipart request without divider definitions and without length definition.<br />
Setting both manually also is not possible due to not being able to access the length of the generated submit content, and also due to the divider being generated at send time as well.</p>
<p>This seems like a bug to me, any idea where I can report this to?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Werner Punz</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-104453</link>
		<dc:creator>Werner Punz</dc:creator>
		<pubDate>Sun, 01 Aug 2010 15:29:04 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-104453</guid>
		<description>Nice stuff, but so far the FormData object always enforces a multipart xhr  submit, wouldn´t it be better to have the object as well for normal non multipart submit cases, it would ease a lot of things to expose the FormData object to all possible submit cases instead of just having a helper for multipart submits.</description>
		<content:encoded><![CDATA[<p>Nice stuff, but so far the FormData object always enforces a multipart xhr  submit, wouldn´t it be better to have the object as well for normal non multipart submit cases, it would ease a lot of things to expose the FormData object to all possible submit cases instead of just having a helper for multipart submits.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Rouget</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-103190</link>
		<dc:creator>Paul Rouget</dc:creator>
		<pubDate>Mon, 26 Jul 2010 08:41:02 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-103190</guid>
		<description>Need more details here. What do you mean?</description>
		<content:encoded><![CDATA[<p>Need more details here. What do you mean?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Firenze</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-103122</link>
		<dc:creator>Firenze</dc:creator>
		<pubDate>Mon, 26 Jul 2010 01:17:01 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-103122</guid>
		<description>Using this XMLHttpRequest Level 2 form method will open all gates to hell,
malware writters will have a playground they&#039;ve never seen before.

Why don&#039;t you think before you brew such crap code ?</description>
		<content:encoded><![CDATA[<p>Using this XMLHttpRequest Level 2 form method will open all gates to hell,<br />
malware writters will have a playground they&#8217;ve never seen before.</p>
<p>Why don&#8217;t you think before you brew such crap code ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonas Sicking</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-102930</link>
		<dc:creator>Jonas Sicking</dc:creator>
		<pubDate>Sun, 25 Jul 2010 04:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-102930</guid>
		<description>It will work until the user navigates away from the page.</description>
		<content:encoded><![CDATA[<p>It will work until the user navigates away from the page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tobiistgut</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-100384</link>
		<dc:creator>tobiistgut</dc:creator>
		<pubDate>Fri, 16 Jul 2010 22:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-100384</guid>
		<description>How long will the URL provided by File.url work?</description>
		<content:encoded><![CDATA[<p>How long will the URL provided by File.url work?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Rouget</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-100069</link>
		<dc:creator>Paul Rouget</dc:creator>
		<pubDate>Fri, 16 Jul 2010 04:28:01 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-100069</guid>
		<description>Could be this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=572139</description>
		<content:encoded><![CDATA[<p>Could be this bug: <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=572139" rel="nofollow">https://bugzilla.mozilla.org/show_bug.cgi?id=572139</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anshuman</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-99730</link>
		<dc:creator>Anshuman</dc:creator>
		<pubDate>Thu, 15 Jul 2010 07:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-99730</guid>
		<description>can you please provide the info for &quot;manual multipart/form-data encode&quot;  in FF3.6 .... i am using this code but its not working..

&lt;code&gt;
var data = event.dataTransfer;

var boundary = &#039;------multipartformboundary&#039; + (new Date).getTime();
var dashdash = &#039;--&#039;;
var crlf     = &#039;\r\n&#039;;

/* Build RFC2388 string. */
var builder = &#039;&#039;;

builder += dashdash;
builder += boundary;
builder += crlf;

var xhr = new XMLHttpRequest();

/* For each dropped file. */
for (var i = 0; i &lt; data.files.length; i++) {
var file = data.files[i];

/* Generate headers. */            
builder += &#039;Content-Disposition: form-data; name=&quot;user_file[]&quot;&#039;;
if (file.fileName) {
  builder += &#039;; filename=&quot;&#039; + file.fileName + &#039;&quot;&#039;;
}
builder += crlf;

builder += &#039;Content-Type: application/octet-stream&#039;;
builder += crlf;
builder += crlf; 

/* Append binary data. */
builder += file.getAsBinary();
builder += crlf;

/* Write boundary. */
builder += dashdash;
builder += boundary;
builder += crlf;
}

/* Mark end of the request. */
builder += dashdash;
builder += boundary;
builder += dashdash;
builder += crlf;
try{
xhr.open(&quot;POST&quot;, &quot;fu.php&quot;, true);
xhr.setRequestHeader(&#039;content-type&#039;, &#039;multipart/form-data; boundary=&#039; + boundary);
xhr.sendAsBinary(builder);        
return &quot;Uploaded&quot;;
} catch(e) {
  return e;
}

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>can you please provide the info for &#8220;manual multipart/form-data encode&#8221;  in FF3.6 &#8230;. i am using this code but its not working..</p>
<p><code><br />
var data = event.dataTransfer;</p>
<p>var boundary = '------multipartformboundary' + (new Date).getTime();<br />
var dashdash = '--';<br />
var crlf     = '\r\n';</p>
<p>/* Build RFC2388 string. */<br />
var builder = '';</p>
<p>builder += dashdash;<br />
builder += boundary;<br />
builder += crlf;</p>
<p>var xhr = new XMLHttpRequest();</p>
<p>/* For each dropped file. */<br />
for (var i = 0; i &lt; data.files.length; i++) {<br />
var file = data.files[i];</p>
<p>/* Generate headers. */<br />
builder += &#039;Content-Disposition: form-data; name=&quot;user_file[]&quot;&#039;;<br />
if (file.fileName) {<br />
  builder += &#039;; filename=&quot;&#039; + file.fileName + &#039;&quot;&#039;;<br />
}<br />
builder += crlf;</p>
<p>builder += &#039;Content-Type: application/octet-stream&#039;;<br />
builder += crlf;<br />
builder += crlf; </p>
<p>/* Append binary data. */<br />
builder += file.getAsBinary();<br />
builder += crlf;</p>
<p>/* Write boundary. */<br />
builder += dashdash;<br />
builder += boundary;<br />
builder += crlf;<br />
}</p>
<p>/* Mark end of the request. */<br />
builder += dashdash;<br />
builder += boundary;<br />
builder += dashdash;<br />
builder += crlf;<br />
try{<br />
xhr.open(&quot;POST&quot;, &quot;fu.php&quot;, true);<br />
xhr.setRequestHeader(&#039;content-type&#039;, &#039;multipart/form-data; boundary=&#039; + boundary);<br />
xhr.sendAsBinary(builder);<br />
return &quot;Uploaded&quot;;<br />
} catch(e) {<br />
  return e;<br />
}</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srigi</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-99393</link>
		<dc:creator>srigi</dc:creator>
		<pubDate>Tue, 13 Jul 2010 16:18:14 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-99393</guid>
		<description>Can you publish some infoooz about

&quot;read the contents of the file into memory, then manually multipart/form-data  encode it and then finally send it to a server&quot;

I want to code some workaroud for FF v3.6 for Ajax file uploads. Since v3.6 doesn&#039;t support FormData, I need implement this &quot;hack&quot;.</description>
		<content:encoded><![CDATA[<p>Can you publish some infoooz about</p>
<p>&#8220;read the contents of the file into memory, then manually multipart/form-data  encode it and then finally send it to a server&#8221;</p>
<p>I want to code some workaroud for FF v3.6 for Ajax file uploads. Since v3.6 doesn&#8217;t support FormData, I need implement this &#8220;hack&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonas Sicking</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-99239</link>
		<dc:creator>Jonas Sicking</dc:creator>
		<pubDate>Mon, 12 Jul 2010 09:00:08 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-99239</guid>
		<description>Would love to see a testcase. One thing to keep in mind is that we&#039;re unusually strict about same-origin checks. So a page in domain A can&#039;t use the File.url value produced by a page in domain B.

Are you using document.domain or postMessage to transport the fileurl between pages of different domains by any chance?

If the above isn&#039;t a problem, file a bug in bugzilla or send me a testcase (should be easy to find an email address through google or other search).</description>
		<content:encoded><![CDATA[<p>Would love to see a testcase. One thing to keep in mind is that we&#8217;re unusually strict about same-origin checks. So a page in domain A can&#8217;t use the File.url value produced by a page in domain B.</p>
<p>Are you using document.domain or postMessage to transport the fileurl between pages of different domains by any chance?</p>
<p>If the above isn&#8217;t a problem, file a bug in bugzilla or send me a testcase (should be easy to find an email address through google or other search).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://hacks.mozilla.org/2010/07/firefox-4-formdata-and-the-new-file-url-object/comment-page-1/#comment-98797</link>
		<dc:creator>David</dc:creator>
		<pubDate>Thu, 08 Jul 2010 16:56:59 +0000</pubDate>
		<guid isPermaLink="false">http://hacks.mozilla.org/?p=5237#comment-98797</guid>
		<description>Trying to set the source of an image using Firefox 4 Beta 1, jQuery, and File.url spec. The File.url property is returning a string (moz-filedata:xxxxx...), but when set as the src for the image, nothing comes back.

Any ideas? Thanks.</description>
		<content:encoded><![CDATA[<p>Trying to set the source of an image using Firefox 4 Beta 1, jQuery, and File.url spec. The File.url property is returning a string (moz-filedata:xxxxx&#8230;), but when set as the src for the image, nothing comes back.</p>
<p>Any ideas? Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

