W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2011

[whatwg] data: URI origin

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 14 Jun 2011 22:19:19 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1106142216270.19153@ps20323.dreamhostps.com>
On Mon, 14 Mar 2011, Luis Marsnao wrote:
> I'm attempting to write a client-side script that processes a user 
> selected file through an input element. Since the input element 
> interface conceals the file: URI, the best solution I can think of is to 
> access the file through the input element's interface, get its data: URI 
> through readAsDataURL in FileAPI's FileReader interface, and process the 
> data: URI. However, I get not-same-origin errors when I try to use this 
> URI. Specifically, this happens when I try to use XMLHttpRequest to 
> retrieve an XML resource with the data URI.

With XHR, yes, that's normal, as I understand it. You can't usefully use 
XHR with data: URLs.

With <iframe>s you should be able to read the content.

> Is there a better way to process files in a client-side script? I 
> considered using blob: URIs, but the support is not yet there.

FileReader is the way you're supposed to do it from a File object.


Since you have a data: URL, you could also just decode the data: URL 
yourself. It contains all the data.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 14 June 2011 15:19:19 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:06 UTC