By Alexandre


2010-11-24 20:03:41 8 Comments

I have been developing an AJAX application using jQuery and Microsoft Seadragon technology.
I need to have access to the html5 canvas function toDataURL.

With Google Chrome, the same origin rule applies to this function which means that a page run locally (with the file:/// in the URL) failed to satisfy the same origin rule and an exception is thrown.

With Chrome 7, starting the application with --allow-file-access-from-files option, allows to call canvas.toDataURL() from local files.

However, it seems that starting the Chrome Beta 8 with the same option (--allow-file-access-from-files) does not allow the call canvas.toDataURL() on the local file.

Does Chrome gave up on the --allow-file-access-from-files option or it has just been disabled since it is a Beta release and not a full release?

Thanks!

5 comments

@Vanuan 2011-04-29 17:36:32

To summarize all answers so far.

Before running chrome, make sure there are no chrome processes running.

Windows

-allow-file-access-from-files

(with one dash)

Linux

--allow-file-access-from-files

(with two dashes)

@dtroy 2012-10-18 12:34:45

This + closing all open windows was the only way it worked on windows.

@Jason 2014-04-21 21:24:55

One dash does the trick for me, on Chrome Version 34.0.1847.116 m. I used 'tskill chrome' before running the command to make sure all Chrome windows were closed.

@Ivo Wetzel 2010-11-24 21:08:17

Looking at the issues for this shows that the whole --allow-file-access-from-files thing was rushed.

  1. "Firefox does it.."
  2. "How can we do it?"
  3. some time passes
  4. "Here are the patches"
  5. "Passes! On trunk wonder what happens in the next dev release"
  6. "Ahhh it's broken" "Use the command line option" "ok"
  7. "We shipped!"
  8. "WTF guys? You broke all my stuff! Why didn't you tell us earlier?"
  9. silence

On to your Problem
Indeed it seems that this is something special to the beta, I'm using Chrome 8.0.552.5 dev here and --allow-file-access-from-files works like expected, I've also tested this with Chromium 9.0.592.0 (66889) were it also works as expected.

I suspect there have been some changes on the dev branch. Unfortunately, finding something on chromium's issue tracker is nearly impossible.

@temporary_user_name 2013-08-28 00:18:22

How can you do the --allow-file-access-from-files thing? I don't really understand how that works.

@Daniel Cheung 2015-01-19 10:55:00

@Aerovistae, A. open your Chrome shortcut's properties, add that to the target: "...\chrome.exe --allow-file-access-from-file" (notice the quotes) || B. using your Command Prompt, run Chrome with the tag ...\chrome.exe --allow-file-access-from-file

@Daniel Cheung 2015-01-19 11:15:40

@Aerovistae, and esacpe "(" and " " with ^( and ^ if you are using cmd

@Johnydep 2011-06-08 10:11:07

The trick that woked for me is that you have to give the absolute path of the file and not just file name in your HTML code. e.g file://... instead of direct name even though you are accessing the file in the same directory. It will work!

@Rob 2013-06-13 16:20:49

Not sure what version of chrome but 27 gives the following error: "Cross origin requests are only supported for HTTP."

@CommissarXiii 2011-05-10 01:32:23

I've found a way around the issue using a JavaScript/Flash approach. If flash is compiled in the Local Only security sandbox, it has full access to local files. Using ExternalInterface, JavaScript can request a Flash Application to load a file, and Flash can pass the result back to JavaScript.

You can find my implementation here: https://code.google.com/p/flash-loader/

@Jeremi Stadler 2012-04-28 20:39:11

Good workaround but gives a very bad dependency on flash

@Guillaume86 2011-03-03 17:37:48

Did you close all chrome instances before opening with the command line argument? You have to do that to make that parameter work.

@BlueMonkMN 2011-10-30 15:11:07

Wow, I was trying everything and then this is the trick that fixed it for me.

@jrsconfitto 2012-04-16 18:27:21

i dont like that. Can you get around this by forcing it to spawn in a new window?

Related Questions

Sponsored Content

7 Answered Questions

[SOLVED] XMLHttpRequest cannot load XXX No 'Access-Control-Allow-Origin' header

31 Answered Questions

[SOLVED] Disable same origin policy in Chrome

32 Answered Questions

[SOLVED] How do I create a Java string from the contents of a file?

68 Answered Questions

[SOLVED] Disabling Chrome Autofill

31 Answered Questions

9 Answered Questions

21 Answered Questions

[SOLVED] Remove blue border from css custom-styled button in Chrome

  • 2013-12-02 23:45:23
  • eshellborn
  • 726711 View
  • 716 Score
  • 21 Answer
  • Tags:   css google-chrome

10 Answered Questions

3 Answered Questions

[SOLVED] Using iframe with local files in Chrome

Sponsored Content