Jump to content


Photo

Preview De Foto Em Upload


  • Faça o login para participar
11 replies to this topic

#1 mi7chael

mi7chael

    12 Horas

  • Usuários
  • 266 posts
  • Sexo:Masculino

Posted 17/08/2007, 11:53

Pessoal, estou com um probleminha: num sistema de upload, eu quero por um preview da foto antes do upload. Eu fiz um codigozinho, até que deu certo, só que só funcionou no IExplorer; no Firefox e opera aparece um espaço em branco onde deveria aparecer a foto. O código beeeeeem simplificado tá aí em baixo:

<script>
function preview() {
	document.foto_preview.src = document.upload.imagem.value;
	document.foto_preview.width = 160;	
	document.foto_preview.height = 116;
}
</script>
<body>
<form name="upload" enctype="multipart/form-data" method="post" action="" />
<input id="formupload_campo" type="file" name="imagem" style="width:320px; height:20px;" onchange="preview()" /><br />
<img src="space.gif" name="foto_preview" /><br />
<input id="formupload_botao" type="submit" name="Submit" value="Enviar Foto" /><br />
</form>
</body>

Eu acredito que o erro é no processo de criação de imagens no firefox e no opera, pq aparece um quadro branco e quando eu clico nele com o botão direito >> propriedades, a url tá lá certinha, ou seja, tá tudo certo, a imagem está lá, só que não aparece. Dei uma pesquisada sobre isso mas não consegui nada não. Se alguém conseguir ajudar...

Edição feita por: mi7chael, 17/08/2007, 11:53.


#2 bimonti

bimonti

    Super Veterano

  • Usuários
  • 2654 posts
  • Sexo:Masculino

Posted 17/08/2007, 13:33

Tenta mudar a imagem, ao invés de name use id, e na função use document.getElementById('id_que_vc_escolheu').
WebFórum - Equipe de Desenvolvimento - Monitor
Posted Image
Yeah I do have some stories, and it's true I want all the glory ...

#3 mi7chael

mi7chael

    12 Horas

  • Usuários
  • 266 posts
  • Sexo:Masculino

Posted 17/08/2007, 15:16

Man, eu fiz como vc disse, só que não deu certo. Continua funcionando só no IExplorer. No Opera e Firefox não dá nada. No Opera ainda aparece o espaço da foto, mas fica em branco, e o ff nem dá sinal de vida. Eu tentei de duas maneiras, assim:

document.upload.imagem2.value = document.upload.imagem.value;
document.getElementById('foto_preview').src = document.upload.imagem.value;
document.getElementById('foto_preview').width = 160;
document.getElementById('foto_preview').height = 116;

<img src="" id="foto_preview" width="" height="" />

E assim:

document.getElementById('foto_preview').src = document.getElementById('formupload_campo').value;

Mas ficou na mesma, só funfa no IExplorer.

#4 Allan Carvalho

Allan Carvalho

    Òó :: ^^

  • Usuários
  • 471 posts
  • Sexo:Masculino
  • Localidade:Campinas - SP
  • Interesses:Um PC novo e rápido. ^^

Posted 18/08/2007, 00:42

Repare:

<script>
function preview() {
var fp = document.getElementById('foto_preview');
fp.src = document.getElementById('imagem').value;
fp.width = 160;
fp.height = 116;
}
</script>
<body>
<form name="upload" enctype="multipart/form-data" method="post" action="" />
<input id="imagem" type="file" name="imagem" style="width:320px; height:20px;" onchange="preview();" /><br />
<img src="space.gif" name="foto_preview" id="foto_preview" /><br />
<input type="submit" name="Submit" value="Enviar Foto" /><br />
</form>
</body>


Flw!
Nome: Allan V. Ferreira de Carvalho.
Localidade: Campinas - SP
Linguagem de desenvolvimento: XHTML | CSS (Tableless) | JavaScript | AJAX | PHP
Contatos: brkamikasecps@gmail.com | brkamikasecps@hotmail.com

Posted Image


#5 mi7chael

mi7chael

    12 Horas

  • Usuários
  • 266 posts
  • Sexo:Masculino

Posted 20/08/2007, 09:32

Allan, eu coloquei do jeito que vc falou, mas ainda não deu certo. Só funciona no IExplorer. Eu até acrescentei um campo text só pra ver a url que ele tá carregando, pra ver se tá funcionando. A URL aparece certinha no campo, tanto que quando eu copio e colo ela no navegador, aparece a imagem q eu selecionei. Olha aí o código com o campo amais:

<script>
function preview() {

var fp = document.getElementById('foto_preview');
fp.src = document.getElementById('imagem').value;
fp.width = 160;
fp.height = 116;

document.getElementById('imagem2').value = document.getElementById('imagem').value;
	
}
</script>

<body>
<form name="upload" enctype="multipart/form-data" method="post" action=""/>
	<input id="imagem" type="file" name="imagem" style="width:320px; height:20px;" onchange="preview()" /><br />
	<input type="text" name="imagem2" id="imagem2" style="width:320px; height:20px;" value="" /><br />
	<img src="" id="foto_preview" name="foto_preview" width="" height="" /><br />
	<input id="formupload_botao" type="submit" name="Submit" value="Enviar Foto" /><br />
</form>
</body>


#6 mi7chael

mi7chael

    12 Horas

  • Usuários
  • 266 posts
  • Sexo:Masculino

Posted 23/08/2007, 16:54

Pessoal, eu fiz de outra maneira, mas tb não deu certo. O problema eu acho q já sei qual é, são os espaços no nome da foto. Acho que tá dando erro por isso.

<script>
function preview() {
document.getElementById("imagem").innerHTML = "<img src=" + document.getElementById("file").value + " />"
}
</script>

<body>
	<form id="form1" >
	<input name="file" type="file" onchange="preview()" id="file" />
	</form>
	<div id="imagem"></div>
</body>

Edição feita por: mi7chael, 23/08/2007, 16:56.


#7 drhouse

drhouse

    Turista

  • Usuários
  • 35 posts
  • Sexo:Não informado

Posted 19/02/2010, 19:14

Teria como adicionar neste script para aceitar mais de 1 imagem tipo 4, e ser mostradas?
www.pontoclassificados.com

#8 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 13/09/2017, 17:17

Provera Medicine In Us Cash Delivery cialis buy online Overnight Stendra In Internet Shop Dove Acquistare Cialis In Italia Proscar Y Propecia Propecia Once Per Day cialis Purchase Orlistat 60 Mg
Acheter Viagra Marocain cialis Viagra Prix Maroc
Cephalexin Alcohol Interaction Buy Flomax Brand
Buy Amoxicillin Online Rush Delivery <a href=http://cialtobuy.com>cialis</a> Where To But Viagra Without Dr.

#9 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 25/09/2017, 13:18

Nolvadex For Cheap cialis Buy Lasix Generic Canadian Pharmacy Propecia 20mg

#10 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 15/10/2017, 06:51

Cialis Non Agisce Viagra Come Fare extra super levitra frumforum.co Progesterone Germany Price Overseas
Levitra 10 Mg Basf Acheter Cialis Andorre mail order pharmacy levitra Buy Clomid Express Shipping Make Your Own Amoxicillin
Buy Prednisone Online Cialis Dosierung Wirkung buy viagra online Kamagra Billig Online Viagra Bestellen Per Nachnahme

#11 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 30/10/2017, 08:10

Viagra Nebenwirkungen Flush Cialis In Der Apotheke Discount Generic Isotretinoin Website Mastercard Store Winston viagra Provera For Sale Mastercard Accepted Low Price Myambutol Cialis Online Tadalafil

#12 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 21/11/2017, 06:46

Cheapestvigorapills online pharmacy Differenza Viagra Generico Cialis Generika Versand Deutschland Amoxicillin Side Effects Children
Canadian Atarax Cialis 20 Mg Tadalafil cheap cialis Viagara For Men
Cialis Tablets For Sale Au buy viagra Cialis 2.5 Mg From Canada Indomethacin Comprar Online Generika Viagra Bestpreis
Cialis Prescription Online Cialis Bon Prix Farmaci Contenenti Dapoxetina viagra online Lioresal Prix Metformin Taken With Amoxicillin How To Get Astelin Nasal Spray




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq