I'd like to be able to specify a local file path for an image on a web page delivered via http using Chrome - is this possible?
I remember doing this using IE but cannot remember how! Some trusted settings I think...
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityyou can convert the image to base-64 code, for example with "https://www.base64-image.de/" and copy the result to browser! Like:
<img width='16' height='16' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAApklEQVQ4jWP8//8/Ay5Q4s6GU7Jn5y9GBgYGBiacuokELKTYSpQByKB68UkMMUExQ0ZkPsVeYEQPREZGRpK8gOGCdy/PwTEyH8ZGF8MbBgwMDAxC4kZ4xfAaALMFGfz//5+6gYjXBS+fXUHhaxjEMqKrQXGBglU8SgyIS+mgYHR5DAPIAYz////HavL5DQVwtmHABAyND44tZGRgwBMG2DRhAxR7AQBhgT3yD6eBRwAAAABJRU5ErkJggg=='>
Since you mentioned 'Chrome', you could use Chrome extensions to do this, to enable local access to your files.
Follow these steps:
{"name": "File Exposer", "manifest_version": 2, "version": "1.0", "web_accessible_resources": ["*.jpg","*.JPG"]}
Put this in your chrome address bar: chrome://extensions/
Make sure 'Developer mode' is checked (Top right of page)
Click the 'Load Unpacked Extension' button
Navigate to the local folder where the image(s) and the manifest.json file is, click ok
The extension 'File Exposer' should now be listed in the list, and have a check mark against 'Enabled'. If the folder is on a network drive or other slow drive or has lots of files in, it could take 10-20 seconds or more to appear in the list.
Note the 'ID' string that has been associated with your extension. This is the EXTENSION_ID
Now in your HTML you can access the file with the following, changing the 'EXTERNSION_ID' to whatever ID your extension generated:
<img src='chrome-extension://EXTENSION_ID/example1.jpg'>
Note, that the *.jpg is recursive and it will automatically match files in the specified folder and all sub folders, you dont need to specify for each sub folder. Also note, its Case Sensitive.
In the 'img' tag you dont specify the original folder, its relative from that folder, so only sub folders need to be specified.
If you modify the manifest.json file, you will need to click the 'Reload (Ctrl+R)' link next to the extension.
Non-local web pages cannot access local files in Chrome or any modern web browser.
You can override this using LocalLinks (for Firefox), but it will only work in your own machine.
about:blank
page and it was not allowing it, I tired opening a local HTML file and it worked, even for images in spite of what @WillemD'Haeseleer said. My code was this: drawing = new Image(); drawing.src = "C:/Users/S/Videos/net.png";
in Chrome this looks like this
file:///C:/sample.txt
If you want to test local image on the live site you can run local web server and set URL like http://127.0.0.1:8123/img.jpg on page using DevTools
There is different ways to run a web server: 1. Extension for browser "Web Server for Chrome" with defined folder https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb
If you have python then run embedded http server at chosen folder
python3 -m http.server 8123 # python 3 version
python -m SimpleHTTPServer 8123 # python 2 version
My, what a difference ten years makes! Found this drop-dead-simple method at https://umaar.com/dev-tips/174-drag-drop-image-local-overrides/
Open the Chrome inspector preferences.
Check "Enable Local Overrides."
Locate the original image in the html.
Right-click the file path, and choose "Locate in Sources Panel."
With the image selected in the left panel of the Sources panel, drag the replacement image from your desktop and onto the preview panel on the right.
As you hover, you'll see a dotted outline with the text "Drop image file here." Drop image file there. ;-)
You may need to refresh the page for the new image to display. Yes, it will persist as long as the Inspector is open and "Local Overrides" is enabled.
NOTE: The file name will not change in the browser, but the new image will display where the original one displayed previously.
In my case, I only needed to see what one small image change would look like in different responsive sizes. It was easiest to Save as... a complete webpage to the desktop and then open that instead. I inspect and edit the image src.
Okay, you can't just let somebody else acess your local file system! You would need a server-service like Apache, let your computer run 24h a day, make sure it wont overheat, care for good security and much more to make that even possible. And because server-administration is expensive and time-consuming, most people let the pro's host our stuff for us (Webhosting).
In conclusion, if you don't want to run your own server, it's much easier to just upload it to your webhoster of choice.