Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/12/2005, 12:40
angsanchez
 
Fecha de Ingreso: octubre-2004
Ubicación: España
Mensajes: 894
Antigüedad: 20 años, 4 meses
Puntos: 3
código mejorado

He conseguido ajustar el tamaño:
Código:
<form>
<script type="text/javascript">
function foto(img)
{	var arch = "file:///" + img.replace(/\\/g,"/")
	arch = arch.replace(/ /g,"%20")
	document.getElementById("foto_view").style.backgroundImage = "url("+arch+")"
	var imag = new Image()
	imag.src = arch
	document.getElementById("foto_view").style.width = imag.width + "px"
	document.getElementById("foto_view").style.height = imag.height + "px"
}
</script>
Elige imagen<input type="file" onChange="foto(this.value)">
<div id="foto_view" style="width:2px; height:2px;"></div>
</form>
Falla algunas veces, no sé muy bien por qué; quizás dependa del nombre y ruta; he filtrado los espacios y ha ayudado, pero aún algunos fallan.
__________________
Angel :cool: