View Full Version : changing image FIREfox issue

03-04-2005, 04:21 PM

The goal:
A user selects an image fil on his pc true an input file field.
A javascript function display's a preview on it next to the file field (without actually oploading the file)

The RPoblem:
I used a JS before but it's not Firefox compatibel so I'm trying to fix it

old JS:

<script language="Javascript" type="text/javascript">

function setImage1(string){
document.getElementById('previewfoto1').src = 'File:\/\/' + string;

What I got now but doesnt work

<script type="text/javascript" language="javascript">
function setImage(string)
var image =document.getElementById('previewfoto1').
image.Setatrribute('src','File:\/\/'+ string);

//also tried this
image.src='File:\/\/'+ string';

the script is called like this:
<input type="file" name="foto'.$i.'" id="foto'.$i.'"onchange="setImage(this.value);"></span>
<span class="right"><img width="50" id="previewfoto1" src="../images/site/tableft.gif" alt="preview" ></span>';

03-04-2005, 09:53 PM
I can't get Gecko to use the file:// protocol with an image src. Could be a security feature.