Unusual issue with HTML image and 'file://' specified src
Question: I'm loading an image on the page with a 'file:///some_dir/image.jpg' src path.
I can access the image in a regular tab using this path. Also, saving the page
as HTML and using this path for the image works. However, the image does not
load on the live page. In chrome it shows part of the alt text, and in firefox
it shows a narrow strip. I have tried changing width and height but to no
avail. Is there something I'm missing?

    
    
    <img title="Click to enlarge" src="file:///Users/Aram/uploads/profile.image.985b0f707d972bf3.4372696242656464696e67616e645465657468696e67437269625261696c436f7665722e6a7067.jpg" class="profile-image">
    

**EDIT:**

I noticed I am getting this in the console:

> Not allowed to load local resource

Is there any way around this?

**EDIT 2:**

Since I could not access the image through an http path, I have decided to
read it in as base64 data. For anyone else using web2py or another Python
framework:

    
    
    # Load the image data
    import os
    path = os.path.join(request.folder, 'uploads', filename)
    data_uri = open(path, 'rb').read().encode('base64').replace('\n', '')
    data = 'data:image/png;base64,%s' % data_uri
    return html.IMG( _src=data, _class='profile-image', _title='Click to enlarge' )
    


Answer: Websites are not allowed to use local files on the user's computer. Use a
relative path to from the html file's directory.

You can also encode and embed the image directly:

How to embed the encoded stuff:
<http://www.sweeting.org/mark/blog/2005/07/12/base64-encoded-images-embedded-
in-html> Python Encoding Instructions: <http://www.daniweb.com/software-
development/python/code/216635>

