I’m trying to load in image in Javascript that’s on my computer, so that I can make a sprite for a game. I don’t have this html on the web yet, and the image is saved locally on my computer. Is this possible to do as the book I’m learning from loads the image from a folder, but I’m unable to load the image. Heres some of my code. Thanks,
$(document).ready(function(){
var params ={
images: 'C:\EclipseWorkspaces\WebTest\images\Luigi.png',
imagesWidth: 256,
width: 64,
height: 64,
$drawTarget: $('#draw-target')
};
var sprite1 = DHTMLSprite(params),
sprite2 = DHTMLSprite(params);
sprite2.changeImage(5);
sprite1.draw(64,64);
sprite2.draw(352, 192);
});
</script>
</head>
<body>
<div id="draw-target">
</div>
</body>
You cant access to HD with Javascript. It would be security violation if you could so.
You can load the image in three ways.
1 You can use an image from the web
2 Use a server side program to load the image, and then pass it to your client side javascript.
3 You can do that with relatives path (../images/myImg.png)
Take a look at this article in Wikipedia:
http://en.wikipedia.org/wiki/JavaScript#Security