Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch html using Chrome at "--allow-file-access-from-files" mode?

I have the same situation with HERE

And to solve this problem I have to launch html file using Chrome at "--allow-file-access-from-files" mode. I tried next steps many times, but it doesn't work.

  1. start cmd under windows 7
  2. direct to chrome.exe folder
  3. do this chrome --allow-file-access-from-files file:///C:/test%20-%203.html
like image 926
AmyWuGo Avatar asked Sep 03 '13 07:09

AmyWuGo


People also ask

Can Chrome access local files?

For security reasons, by default the Chrome browser does not allow extensions to access local files. If you want the accelerator to access local files (locations of "file:///...", instead of "http://" or "https://"), you must configure Chrome to allow the access.


2 Answers

That flag is dangerous!! Leaves your file system open for access. Documents originating from anywhere, local or web, should not, by default, have any access to local file:/// resources.

Much better solution is to run a little http server locally.

--- For Windows ---

The easiest is to install http-server globally using node's package manager:

npm install -g http-server

Then simply run http-server in any of your project directories:

Eg. d:\my_project> http-server

Starting up http-server, serving ./ Available on:  http:169.254.116.232:8080  http:192.168.88.1:8080  http:192.168.0.7:8080  http:127.0.0.1:8080 Hit CTRL-C to stop the server 

Or as prusswan suggested, you can also install Python under windows, and follow the instructions below.

--- For Linux ---

Since Python is usually available in most linux distributions, just run python -m SimpleHTTPServer in your project directory, and you can load your page on http://localhost:8000

In Python 3 the SimpleHTTPServer module has been merged into http.server, so the new command is python3 -m http.server.

Easy, and no security risk of accidentally leaving your browser open vulnerable.

like image 89
orszaczky Avatar answered Sep 28 '22 06:09

orszaczky


Search for the path of your Chrome executable and then, on your cmd, try :

> "C:\PathTo\Chrome.exe" --allow-file-access-from-files 

Source

EDIT : As I see on your question, don't forget that Windows is a little bit similar to Unix, so when you type "chrome ...", cmd will search for Chrome in the PATH, but in general the Chrome folder isn't on the PATH. Also, you don't specify an extension for your executable... So if you move to Chrome's folder, this command will probably work too :

> .\chrome.exe --allow-file-access-from-files 
like image 27
Mohamed Amine Avatar answered Sep 28 '22 05:09

Mohamed Amine