User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,564 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,567 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3349 | Replies: 6
Reply
Join Date: Sep 2007
Posts: 7
Reputation: Ninad is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Ninad's Avatar
Ninad Ninad is offline Offline
Newbie Poster

Question displaying local (client side) images in webpage

  #1  
Oct 22nd, 2007
Is there any client side java-script to read local path like "c:\my documents\xyz.jpg" and then display image on web page

I have an xml file which contains local file path and i want to display the thumbnail of all those files on my web page ...


This thing cant be done on server side ..

plezz help me with some sample code

thanks in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 1,289
Reputation: vishesh is on a distinguished road 
Rep Power: 5
Solved Threads: 32
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: displaying local (client side) images in webpage

  #2  
Oct 22nd, 2007
What do you exactly mean. I really couldn't understand the problem well. I could not make assumption too
Reply With Quote  
Join Date: Sep 2007
Posts: 7
Reputation: Ninad is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Ninad's Avatar
Ninad Ninad is offline Offline
Newbie Poster

Re: displaying local (client side) images in webpage

  #3  
Oct 22nd, 2007
Originally Posted by vishesh View Post
What do you exactly mean. I really couldn't understand the problem well. I could not make assumption too
i want to pick all the image files in a given dir path at clientside and display it on my webpag ..

i cant access those files on server side if i say <img src = "c:\a.jpg"/> it will search on server. I dont want that. i m looking for a javascript (as js runs on client machine) which will parse the xml (i hav xml containing the path of local image files) and get the path and display the image by retriving the file (from the given path) on local machine i.e. is on client side
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 7,012
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 368
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: displaying local (client side) images in webpage

  #4  
Oct 22nd, 2007
All browsers come with a built in XML parser which can be used to load XML files which can then be accessed using DOM. Read this for reading local XML files.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 971
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: displaying local (client side) images in webpage

  #5  
Oct 24th, 2007
Whether or not a browser allows a page to reference files on a user's computer in any way is dependant on the browser and perhaps security settings; although, it's certainly been possible in previous IE versions to display images that are stored on a user's PC via a webpage, regardless of the host of the webpage. For that user only of course...

This works for me in IE6:
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <img src="file://c:/synd.gif"/>
  6. </body>
  7. </html>

But not in Opera or Firefox.. Dunno about IE7. Opera and Firefox only allow this when the host is the localhost - in other words; when the page referencing the image is also on the user's PC.
Plato forgot the nullahedron..
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 7,012
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 368
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: displaying local (client side) images in webpage

  #6  
Oct 26th, 2007
Accessing resources on the users computer doesn't mandate the use of absolute pathing. We can still use relative paths and at the same time access the images on the users computer provided the hierarchy / folder structure is well defined and considering the path / folder where our HTML resides as the root.
Last edited by ~s.o.s~ : Oct 26th, 2007 at 1:02 pm.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 971
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: displaying local (client side) images in webpage

  #7  
Oct 26th, 2007
If the entire site/page is offline, yes... I'm not 100% sure on the OPs requirements, but 'web page' implies a page on the web; and if the page really is hosted on the web ( i.e. on a host that cannot be assumed to be the localhost ); then the obvious way to access anything on a given user's machine from that webpage is using an absolute path starting with 'file://' as per that example ( and to my knowledge this only works with < IE6[7??], and only with images ).. If the site/page that requests the image is also on the localhost, then no problem, it will work in any browser: use relative, absolute, or root-relative paths, whatever you prefer.

But I don't think that's the case, read the posts, the OP specifically says 'i cant access those files on server side if i say <img src = "c:\a.jpg"/> it will search on server.' Forcing the browser to use the file:// protocol instead http:// protocol in theory will allow the browser to access files on the user's own filesystem; in practice it wont work reliably - not all browsers will allow it in all circumstances - because it's dangerous. BUT it will always work, if the page and the image are sourced from the same host... e.g. if the .html file is saved on the same computer as the .gif/.jpg/etc files.
Plato forgot the nullahedron..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 5:48 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC