By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,686 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,686 IT Pros & Developers. It's quick & easy.

Retrieve image files from local system

P: 65
How can i retrieve image files from a local system's My pictures folder and display those images?
May 9 '08 #1
Share this Question
Share on Google+
10 Replies


acoder
Expert Mod 15k+
P: 16,027
JavaScript doesn't allow access to the local file system, so this isn't really possible by just setting the src of images to the local filepath.

What you can do is use an input file element and upload the file to the server and then display it.
May 9 '08 #2

KalariaNitya
P: 34
for that, u have to make one function on server side which manage current folder path

and called that function from inline on that img button..

Expand|Select|Wrap|Line Numbers
  1. <A href='<%#FormatURL1(DataBinder.Eval(Container.DataItem,"prod_id"))%>'  onclick="window.open(this.href,'','scrollbars=no, menubar=no, toolbar=no, resizable=yes, status=no, width=800, height=600'); return false;" target="_blank"><asp:Image id="Image1" runat="server" CssClass="border_img" ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem,"prod_id")) %>' BorderStyle="Solid" BorderWidth="1px">
  2.  
where FormatURL1 is server side function
May 10 '08 #3

gits
Expert Mod 5K+
P: 5,390
as acoder said already: javascript doesn't allow access to the local filesystem of the client ... and it should NOT! ... imagine a webpage that could access your filesystem ... nobody wants that. of course you could use some privileges or security settings in an environment where you could control such things (local machine or an intranet) ... but on a public site you cannot control the users settings ...

kind regards
May 10 '08 #4

P: 65

acoder
Expert Mod 15k+
P: 16,027
Yes, but have you read the page properly? It requires ActiveX, works in IE only, the security must be lowered, a security warning pops up, etc.
Jun 7 '08 #6

P: 65
Yes, but have you read the page properly? It requires ActiveX, works in IE only, the security must be lowered, a security warning pops up, etc.

yes, i know that.

But using the same way is it possible to retrieve image files from the local system?
Jun 7 '08 #7

gits
Expert Mod 5K+
P: 5,390
is that a question? the answers are up there already. if you have an IE - and an IE not on a MAC - so: if you have an IE and windows and lower the security settings and use ActiveX - you may retrieve files from the local file system ... so the answer is yes. but as you see ... this is really useless for a public webpage ... but it could make sense for a intranet-environment where you have control over all that things that are preliminaries for that 'solution' ...
Jun 7 '08 #8

acoder
Expert Mod 15k+
P: 16,027
One thing that can be added is that IE6 will allow you to set the source of an image to a local file by default. IE7 wouldn't by default and neither would other browsers.
Jun 7 '08 #9

rnd me
Expert 100+
P: 427
One thing that can be added is that IE6 will allow you to set the source of an image to a local file by default. IE7 wouldn't by default and neither would other browsers.

seems to work in firefox:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head><title>local image test</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <style type='text/css'></style></head><body >
  6.  
  7. image url:<input type='text'  id='url' value=''  />    &nbsp;<input type='button'  id='' value='load it' onclick="loadit()" />    <br />
  8.  
  9. <br /><hr />
  10.  
  11. <img src="hello.jpg"  id="img" alt="" border="0"    />    
  12.  
  13. <hr />
  14.  
  15. <script type='text/javascript'>
  16.  
  17. function el(tid) {return document.getElementById(tid);}
  18.     function loadit(){
  19.         el("img").src=el("url").value;    
  20. }
  21.  
  22.  
  23. </script></body></html>
Jun 8 '08 #10

acoder
Expert Mod 15k+
P: 16,027
Either you're testing locally, or you've changed the default settings. It doesn't work for me. You may have security.checkloaduri set to false if it's working non-locally.
Jun 8 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.