chenhuanle / html5rocks

Automatically exported from code.google.com/p/html5rocks
0 stars 0 forks source link

Any workarounds for the "cross-origin" problem? #758

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I started working on a JS app that does simple image processing.

The main idea was to perform everything locally on user's computer, to avoid 
uploading files, waiting without the progress bar, overloading the server, etc.

Unfortunately, HTML-5 is not fit to this task. The "cross origin" problem 
prevents any access to image pixels, unless they are uploaded to the server. 
Which is problematic if image is 12 mpix and you don't have a symmetric DSL 
connection. Even if the customer personally picks the file, web browser ignores 
his request and blocks JS from executing the desired image filters. A bit 
irritating, right?

So, my question is: 
Any workaround for this problem? Something that would enable JS apps to access 
local images (chosen and confirmed by the user) and thus compete in 
functionality with desktop apps? For now I'm considering switching to Flash, 
which allows local processing rather than uploading to the server.

Original issue reported on code.google.com by zex2...@gmail.com on 3 Jan 2012 at 12:17

GoogleCodeExporter commented 9 years ago
Many options. Have you seen: 
http://www.html5rocks.com/en/tutorials/file/dndfiles/

Original comment by ericbide...@html5rocks.com on 3 Feb 2012 at 11:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thanks for the suggestion. I just tried it. And immediately bumped into a 
problem. 

The <input type="file"> field cannot return full path to a file. So if I have 
an image file with the following path "samples/image1.jpg" and the user picks 
it, I cannot get the full path to the file. Which means the reader can't load 
it.

Browsing for a file returns the files array. This array should contain the full 
file path, but unfortunately I can't access this information.

When I access the files[0].name property, result is "image1.jpg". Directory is 
missing. Should return "samples/image1.jpg". File reader cannot read a file 
without the proper path.

The mozFullPath property contains the full path when I watch it in debugger 
(FireBug). But when I access it from the code, files[0].mozFullPath returns an 
empty string. No luck again.

Original comment by zex2...@gmail.com on 11 Feb 2012 at 12:32