I have to upload an image onto my HTML page from my local disk, which I know now is not possible because of the security reasons and the same origin policies.
1.) My image 'loadingimage.jpg' is at the same location as my .html page. I did try relative paths like
<style>
body {
background-image: url("/loadingimage.jpeg");
}
</style>
and it gives me error like
Failed to load resource: the server responded with a status of 404 (Not Found)
http://10.2.9.208:8081/loadingimage.jpg
I do not get this error when I open files directly, only when I am using node js express to serve this html file from my disk. I have this code in my node js
app.get('/abt', function (req, res) {
res.sendFile(path.join(__dirname, '../../startpage.html'));
});
Please do not downvote this question as a duplicate as I have gone through all the links and have not been able to find a solution.So, I am reposting it. Can this be done without conversion to base64 codes? What do I do?
2.)But even if I somehow manage to display it on my browser, I want all the clients browsing my webpage to be able to see it, like suppose a WELCOME image. How do I make it possible?
I am not allowed to use any image hosting servers on the web. Can I do something like accessing the client PC and storing the image locally there, using it and then deleting it when the page is closed?.
I have a server machine running in the background, Is it in any way possible to store these images on the server and then retrieve it and display it on the client PC?
EDIT 1: I tried using this
<img class="logo" src="http://10.2.9.208:8081/loadingimage.jpg" alt="My_Logo">
This now, not only gives me the same error, but also displays a broken image.
the fiddle for this : https://jsfiddle.net/SuchitraIyer/sno3j98w/