How to set –allow-file-access-from-files flag option in Google Chrome


To totally unlock this section you need to Log-in


Login
If you have ever tried to develop and test your application in Google Chrome on your local machine you will most possibly face some challenges.

It may be an App (Chrome extension development), an AJAX application using jQuery or offline javascript/html applications, you too may have experienced this issue.

The Google Chrome (and Chromium) browser will not load local file by default due to security reason.

The Solution

Google Chrome has for a long time provided a list that shows the available switches including their conditions and descriptions. Using the --allow-file-access-from-files option you should be able to run your tests in Google Chrome with no hassles.

On Windows Operating System

Get the url of your Chrome Installation path to your chrome installation e.g:

C:\Users\-your-user-name\AppData\Local\Google\Chrome\Application

Launch the Google Chrome browser from the command line window with the additional argument '–allow-file-access-from-files'. For example: 'path to your chrome installation\chrome.exe --allow-file-access-from-files'

Temporary method you can use each time you are testing

  • Copy the existing chrome launcher
  • Do as above and save it with a new name e.g: Chrome - testing
  • Alternatively, you can simply create a new launcher with the above and use it to start Chrome.

    On Linux Operating System (specifically UBUNTU)

    Slightly Permanent Method

  • Go to the menu entry/ launcher for Chrome (.desktop file).
  • Open the launcher properties dialog.
  • It should look something like this: /usr/bin/google-chrome %U
  • Change it to /usr/bin/google-chrome --allow-access-from-files to make the flags work permanently.

    You may also need to delete and re-pin your launcher(s) after modifying it. Chrome should launch with the specified flags enabled after the modification.

    How to set --allow-file-access-from-files flag option in Google Chrome

    How to set --allow-file-access-from-files flag option in Google Chrome

    Checking which flags are Enabled in Google Chrome

    In the browser

    Opening chrome and navigating to the URL chrome://version/ should also list enabled flags in the Command Line block: and that's how you enable the Chrome --allow-file-access-from-files option.