IE7 and "the path" part II

Hi Folks,

I got a problem with some of my scripts with the new version of the
internet explorer (7.0).

It seems like this kind of assign:

document.anyimage.src= "c:\car.jpg"

does not work anymore.
I used it on an "OnChange" event for File2Upload elements, so an user was able to see his selection immediately, worked fine in IE6.
It still works in IE7, but only with a relatative path like "../images/car.jpg".

Can anyone give me a hint on this? Sadly, File2Upload elements return an absolute path.. what can I do on this?
[580 byte] By [AndyTheAce] at [2007-11-20 5:08:54]
# 1 Re: IE7 and "the path" part II
I believe that in IE7 it was finally realized by Microsoft that giving the full path and not a URL path to a file or any such source was a security hole.

You can test it by creating an image and giving it just a direct path using the C:\Path\file as the source.
PeejAvery at 2007-11-8 0:41:34 >
# 2 Re: IE7 and "the path" part II
I already did as I described, it does not work even with a hardcoded absolute path.

So.. what could you do now if you want to display a selected image
immediatly after selecting it (i.e. with file2upload) ?
AndyTheAce at 2007-11-8 0:42:32 >
# 3 Re: IE7 and "the path" part II
EDIT: I just tried the following on IE 7 on my work machine it shows fine.

<img src="G:\Apache2\htdocs\images\work.jpg">
PeejAvery at 2007-11-8 0:43:36 >
# 4 Re: IE7 and "the path" part II
maybe be ..
Didn't try with html, I need it badly working with javascript.

tried it with document.anyimage.src= "c:\car.jpg" ?
AndyTheAce at 2007-11-8 0:44:30 >
# 5 Re: IE7 and "the path" part II
Just use a div and rewrite the content.

<div id="imagediv"></div>

<script language="JavaScript">
document.getElementById('imagediv').innerHTML = "<img src='c:\car.jpg'>";
</script>
PeejAvery at 2007-11-8 0:45:40 >
# 6 Re: IE7 and "the path" part II
First of all, thanks for your help PeejAvery,

I did it like you suggest, but I'm experiencing some problems.

this is the line of code for changing the picture:

document.getElementById('ctl00_ContentPlaceHolder1_lblimage').innerHTML = "<img id='userimg' width='200' height='240' src='" + document.getElementById('ctl00_ContentPlaceHolder1_FileUpload1').value + "'>";

Its just the same way you suggested, just with some long id's.
On the first view it seems to work, but IE7 does not show the image after all!

I made two screenshots for demonstration, this is the above line of code outputed with alert:

http://meet2poker.tempw7.internet1.de/temp/output.jpg

As you can see, it executes the code correctly, but the image is not displayed.

Second screenshot shows the information about the picture:

http://meet2poker.tempw7.internet1.de/temp/file.jpg

It looks like.. he still does not know where the file is located, it just got the filename without the path ?!? I don't know why.. but the src line is correct as you can see in screenshot one.

Doohh I'm confused.
AndyTheAce at 2007-11-8 0:46:41 >
# 7 Re: IE7 and "the path" part II
What does the following code do for you?

<html>
<body>

<script language="JavaScript">
function showimage(){
var img = "<img id='userimg' width='200' height='240' src='" + document.getElementById('ctl00_ContentPlaceHolder1_FileUpload1').value + "'>";
document.getElementById('ctl00_ContentPlaceHolder1_lblimage').innerHTML = img;
}
</script>

<div id="ctl00_ContentPlaceHolder1_lblimage"></div>
<input type="file" id="ctl00_ContentPlaceHolder1_FileUpload1" onchange="showimage()">

</body>
</html>
PeejAvery at 2007-11-8 0:47:32 >
# 8 Re: IE7 and "the path" part II
that code works with a normal html file (IE7 asks me for allowing active content bla bla if I open this in html)

If I put the code to the output of my aspx its the same as I describe in my previous post, no asking for active content, executing the code but NOT showing the picture.
AndyTheAce at 2007-11-8 0:48:41 >
# 9 Re: IE7 and "the path" part II
I would suggest going to Microsoft about it. Contact them. Since IE 7 is rather new, all the knowledge base still is not compiled.
PeejAvery at 2007-11-8 0:49:38 >
# 10 Re: IE7 and "the path" part II
Hola,

I posted this problems a few weeks ago, discussed it with PeejAvery coming to no solution.
Maybe anyone knows something new about it or a workaround:

Simple problem, since IE7 it's not possible to set an absolute file path for example an image.
An assignment like <img src="C:\mypic.jpg"> is recognized but not displayed, except you execute that code on your localhost.

It's possibly some kind of new security option, but it's pretty annoying if you want some kind of preview of an image (file2upload).

If there is any idea out there, I'm happy to hear it.

Best Regards,
Andy
AndyTheAce at 2007-11-8 0:50:39 >