Click to See Complete Forum and Search --> : Problem with image display ??


DaveinLondon
05-24-2006, 04:32 AM
This was thought to be a js manipulation problem - but it isn't its a HTML or browser problem - does anyone know away round it ?


The problem is that Moz FF won't display a local file !

I did this to check it:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Image Display</title>
</head>
<body>

<img src="file:///D:/Web/test/dog.jpg"><br><br>
<img src="http://localhost/test/dog.jpg"><br><br>
<img src="dog.jpg">

</body>
</html>



In IE 6 all 3 images show.

in Moz FF only the last 2 images show.

So Moz FF has dot the image file name but refuses to show it. :mad:

BUT ofcourse if you just enter "file:///D:/Web/test/dog.jpg" into the browser then it shows it !! :)

why ?? - how to get around it ??
Please - anyone got any ideas ??

GaryS
05-24-2006, 04:46 AM
Is the triple forwardslash correct?

DaveinLondon
05-24-2006, 05:18 AM
I have loaded it onto my website

the address is http://www.yodbod.com/changer3.html

please try it in IE 6 and Mox FF

You will see the alerts tracking the file variable name and the final attempt at displaying the image. - Moz FF wont display it ??? :mad:

Any ideas ?

Dave

GaryS
05-24-2006, 05:35 AM
Haven't come across this before... and was rather surprised to find this:

http://kb.mozillazine.org/Links_to_local_pages_don't_work

DaveinLondon
05-24-2006, 07:18 AM
I assume that their would be no way to change the setup of the client pc browser - rather defeat the object !!

I don't want broken images on the screen so ...

... how can I change this script so only IE 6 browsers show the image ?

Here is my code :


<html>
<head>
<script type="text/javascript">

function showImg(){
var fullName = document.forms[0].upLoad.value;
var usePath = fullName.replace(/\\/g,"/")//.replace(/ /g,"%20");
var fileName = fullName.match(/[^\/\\]+$/);
var splitName = fullName.split(".");
var fileType = splitName[1];
fileType = fileType.toLowerCase();
if (fileType == 'gif' || fileType == 'jpg' || fileType == 'jpeg' )
{
usePath = "file:///"+usePath;
document.forms[0].nImage.style.display = '';
document.forms[0].nImage.src = usePath;
}
else {
alert('You must select an image file');
document.forms[0].reset();
}
}
</script>
</head>
<body>

<form>
<table cellpadding="5" cellspacing="0">
<tbody>
<tr>
<td>Add an mage:</td>
<td><input type="file" name="upLoad" onchange="alert(this.value),showImg()"></td>
<td><img width="80" height="60" id="nImage" style='display:none'></td>
</tr>
<tr>
<td><input type="reset" onclick="this.form.nImage.src='';this.form.nImage.style.display='none'"></td>
</tr>
</tbody>
</table>
</form>

</body>
</html>

GaryS
05-24-2006, 07:28 AM
The usual way to do it is to upload the selected image to your webserver. From the user's point of view, the procedure is much the same.

DaveinLondon
05-24-2006, 07:35 AM
Yes - actually i didn't really explain why i wanted to display the image.

I want to display the image that theuser is ABOUT to upload.

if you click on this link you will see what i mean

in IE 6 it works fine
in Mox FF i get a broken image.

so i want to just write the script so that IE 6 displays the image.

link : http://www.yodbod.com/changer2.html

GaryS
05-24-2006, 07:40 AM
Got you. I'm out of ideas. Anyone else?

stutter
05-26-2006, 10:38 AM
well, an idea may be to write an xmlhttp request (ajax) script to actually upload the file before the user submits the form. then you can display the image from your webserver, it will delay things a bit (upload/download) but if the image is relatively small in size, it would be almost negligable.

Probably not the best solution, but seeing as firefox doesn't let you link locally, it doesn't give you much of an alternative, from what i can see :\

DaveinLondon
05-26-2006, 10:41 AM
Interesting idea ! :)

How do i do an ajax ??