Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

AGF

UpLoad com Preview

Recommended Posts

Salve Galera!

Meu primeiro post.Espero não ficarem bravos comigo!

O que ocorre é que, preciso fazer um esquema de upload com preview. Tenho o script, mas não funciona no FireFox! Somente no IE.

 

<script type="text/javascript">

function preview()

{

field = document.getElementById( 'upload' ).value;

image = document.getElementById( 'previewIMG' );

path = 'file://'+ field;

path = path.replace(/\\/, '/');

image.src = path;

image.style.display = 'block';

//alert(image.width +"-"+ image.height);

if(image.width > image.heigth)

{

//paisagem

image.style.width = "100px";

image.style.height = "75px";

}

else

{

//retrato

image.style.width = "75px";

image.style.height = "100px";

}

 

}

</script>

 

<body>

<input type="file" name="upload" id="upload" onchange="preview()"/>

<img id="previewIMG"/>

</body>

 

Alguma solução? Ou outra forma de fazer isso?

 

abração,

 

Alex Gonçalves

Compartilhar este post


Link para o post
Compartilhar em outros sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<script type="text/javascript">

function preview()

{

field = document.getElementById('upload').value;

alert(document.getElementById('upload').value)

image = document.getElementById( 'previewIMG' );

alert(image)

path = field;

//path = path.replace(/\\/, '/');

alert(path)

image.src = path;

image.style.display = 'block';

//alert(image.width +"-"+ image.height);

if(image.width > image.heigth)

{

//paisagem

image.style.width = "100px";

image.style.height = "75px";

}

else

{

//retrato

image.style.width = "75px";

image.style.height = "100px";

}

 

}

</script>

</head>

 

<body>

<input type="file" name="upload" id="upload" onchange="preview()"/>

<img src="" id="previewIMG"/>

</body>

 

</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.