0

I want my browser to open my local images and to place them at the center of my browser. The only way I could think of is by coding an HTML+CSS file, but I don't want to use PHP or ASP.NET cause I don't want to run a server. So javascript is a solution to this.

So, is there a way for an HTML+Javascript file to display a list of my local files, and after clicking at the image I want, the image name to be saved to a variable in order to display this image to my html with img src using the css style I want?

Thanks in advance!

celticharp
  • 155
  • 6
  • 21

2 Answers2

1

This is only possible with some kind of special file system that is based on XML (I've seen this once)

You need to create a XML index file (or some other format you can get with XMLHTTP Web Requests and parse with JavaScript) that contains all information about the images (System location, maybe some kind of ID, alt/title attributes etc.)

Then you load that file with a XMLHTTP Request, parse the data and print it as HTML with correct links to the images.

JavaScript itself can't read the file system, it can request single files only

DarkDevine
  • 1,047
  • 1
  • 9
  • 12
  • I think this is too much for me... Can I just type myhtml.html?src=image.jpg and save the src name to a variable in order to use it to my html? – celticharp Dec 16 '11 at 11:52
  • You can, but how do you want to generate those URLs? You would need to know which images are there in the first place and that is not possible with JavaScript alone if you don't use some kind of tricky file system converter Some other options are writing a little C# application or using PHP/ASP with local Apache/IIS – DarkDevine Dec 16 '11 at 13:02
  • Well, I wont generate the urls, I will have to enter the image filename inside the url... its a little better than editing the html code again and again! – celticharp Dec 16 '11 at 13:52
  • Then why not just open the image in your browser? Or open it in any other tool that can view images? What exactly is the purpose of your "tool"? – DarkDevine Dec 16 '11 at 13:59
0

Accessing local filesystem from Javascript inside a browser is a pretty taboo thing mostly. See this related question.

Community
  • 1
  • 1
Vilx-
  • 104,512
  • 87
  • 279
  • 422