Ir para conteúdo

Arquivado

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

Ericcoutinho.com

Campo p/ Upload de imagem

Recommended Posts

Tentei adaptar um script que um amigo fez pra outro trabalho, mas não entendo nadinha de PHP.

Como esse script era bem mais complicado do que esse que preciso, não consegui editar.

Procurei também aqui no Banco de Scripts e não encontrei dessa forma...

 

Gostaria de inserir um campo para upload de 1 imagem, com tamanho máximo definido (em px) em um simples formulário de e-mail. A imagem nem precisa ir para algum diretório, e nenhuma informação pro banco de dados. Precisa apenas vir anexada no e-mail que vou receber, junto com os demais dados do formulário.

 

Se alguém puder ajudar, segue abaixo o htm e o php que utilizo como padrão:

 

HTML

<html>

<head>

<title>ERICCOUTINHO.COM °design gráfico</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript">

<!--

function MM_findObj(n, d) { //v4.01

var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];

for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);

if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_swapImage() { //v3.0

var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function MM_swapImgRestore() { //v3.0

var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;

}

 

function MM_preloadImages() { //v3.0

var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}

}

 

//-->

</script>

 

<style type="text/css">

<!--

.format {

color: #666666;

font-family: Arial;

font-size: 10px;

background-color: #ffffff;

border: 1px solid #cccccc;

}

-->

</style>

 

 

<script LANGUAGE="JavaScript">

function addbookmark()

{

bookmarkurl="http://www.ericcoutinho.com"

bookmarktitle="ERICCOUTINHO.COM °webdesign °design gráfico °artes"

if (document.all)

window.external.AddFavorite(bookmarkurl,bookmarktitle)

}

</script>

 

</head>

<body bgcolor="#FFFFFF" link="#003366" vlink="#003366" alink="#003366" leftmargin="0" topmargin="0" onLoad="MM_preloadImages('img/hold-contato_f2.jpg','img/hold-favoritos_f2.jpg','img/hold-dg_f2.jpg','img/hold-wd_f2.jpg','img/hold-ap_f2.jpg')">

 

<form action="http://www.ericcoutinho.com/contato/contato.php" method="post" class="c_zero" name="contato" onSubmit="return TestaVal()">

 

<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">

<!-- fwtable fwsrc="index.png" fwbase="index.jpg" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->

<tr>

<td><img src="img/spacer.gif" width="29" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="189" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="24" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="102" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="82" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="108" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="25" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="189" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="30" height="1" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="1" height="1" border="0" alt=""></td>

</tr>

 

<tr>

<td rowspan="5"><img name="lateralesq" src="img/lateral-esq.jpg" width="29" height="405" border="0" alt=""></td>

<td><a href="http://www.ericcoutinho.com/contato"><img name="holdcontato" src="img/hold-contato.jpg" width="189" height="24" border="0" alt=""></a></td>

<td colspan="5"><img name="top" src="img/top.jpg" width="341" height="24" border="0" alt=""></td>

<td><a href="java script:addbookmark()"><img src="img/hold-favoritos.jpg" width="189" height="24" border="0" alt=""></a></td>

<td rowspan="5"><img name="lateraldir" src="img/lateral-dir.jpg" width="30" height="405" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="1" height="24" border="0" alt=""></td>

</tr>

<tr>

<td><img name="basecontato" src="img/base-contato.jpg" width="189" height="27" border="0" alt=""></td>

<td colspan="5"><img name="flash2" src="img/flash2.jpg" width="341" height="27" border="0" alt=""></td>

<td><img name="basefavoritos" src="img/base-favoritos.jpg" width="189" height="27" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="1" height="27" border="0" alt=""></td>

</tr>

<tr>

<td colspan="7"><img name="faixameio" src="img/faixa-meio.jpg" width="719" height="46" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="1" height="46" border="0" alt=""></td>

</tr>

<tr>

<td colspan="7" class="format"><blockquote>

<p align="left">  <strong>  SEU NOME<font size="1" face="Arial, Helvetica, sans-serif">  </font></strong>

<input name="nome" type="text" class="format" size="31">

     <strong>SEU E-MAIL</strong><font size="1" face="Arial, Helvetica, sans-serif"><strong>  

<input type="text" name="email" class="format">

<br>

<br>

     <font color="#003366">confira seu e-mail

para que eu possa te responder</font><br>

<br>

  </strong></font><strong>  ÁREA DE CONTATO</strong><font size="1" face="Arial, Helvetica, sans-serif"><strong>  

<select name="area" class="format">

<option value="WEBDESIGN" selected>WEBDESIGN</option>

<option value="DESIGN GRÁFICO">DESIGN GRÁFICO</option>

<option value="ARTE">ARTE</option>

<option value="TODO O SITE">TODO O SITE</option>

</select>

      </strong></font><strong>ASSUNTO</strong><font size="1" face="Arial, Helvetica, sans-serif"><strong>         

<select name="assunto" class="format">

<option value="DUVIDAS">DÚVIDAS</option>

<option value="ORÇAMENTO" selected>ORÇAMENTO</option>

<option value="IMPRENSA">IMPRENSA</option>

<option value="EXPOSIÇÕES">EXPOSIÇÕES</option>

<option value="SUGESTÕES">SUGESTÕES</option>

<option value="OUTROS">OUTROS</option>

</select>

<br>

<br>

    </strong></font><strong>COMO CONHECEU O SITE?</strong><font size="1" face="Arial, Helvetica, sans-serif"><strong>  

<select name="ref" class="format">

<option value="E-MAIL">E-MAIL RECEBIDO</option>

<option value="INDICACAO" selected>INDICAÇÃO</option>

<option value="LINK">LINK EM OUTRO SITE</option>

<option value="BUSCA NA WEB">BUSCA NA WEB</option>

<option value="OUTROS">OUTROS</option>

</select>

<br>

<br>

    

<textarea name="texto" class="format" cols="98" rows="3">DIGITE AQUI SEU TEXTO</textarea>

   

<input type="submit" name="envia" value="ENVIAR" class="format">

<br>

<br>

     </strong></font><strong>PARA ENVIAR PELO

SEU GERENCIADOR DE EMAIL, CLIQUE NO ENDEREÇO:</strong><strong>

<a href="mailto:email@ericcoutinho.com">email@ericcoutinho.com</a></strong></p>

</blockquote></td>

<td><img src="img/spacer.gif" width="1" height="277" border="0" alt=""></td>

</tr>

<tr>

<td><img name="baseesq" src="img/base-esq.jpg" width="189" height="31" border="0" alt=""></td>

<td><img name="setaesq" src="img/seta-esq.jpg" width="24" height="31" border="0" alt=""></td>

<td><a href="http://www2.ericcoutinho.com" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage('holddg','','img/hold-dg_f2.jpg',1)"><img name="holddg" src="img/hold-dg.jpg" width="102" height="31" border="0" alt=""></a></td>

<td><a href="http://www1.ericcoutinho.com" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage('holdwd','','img/hold-wd_f2.jpg',1)"><img name="holdwd" src="img/hold-wd.jpg" width="82" height="31" border="0" alt=""></a></td>

<td><a href="http://www3.ericcoutinho.com" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage('holdap','','img/hold-ap_f2.jpg',1)"><img name="holdap" src="img/hold-ap.jpg" width="108" height="31" border="0" alt=""></a></td>

<td><img name="setadir" src="img/seta-dir.jpg" width="25" height="31" border="0" alt=""></td>

<td><img name="basedir" src="img/base-dir.jpg" width="189" height="31" border="0" alt=""></td>

<td><img src="img/spacer.gif" width="1" height="31" border="0" alt=""></td>

</tr>

</table>

</form>

</body>

</html>

PHP

<?php

 

/* Função para segurança de dados */

function dadoSeguro ($var) {

$var = str_replace("<", "<", $var);

$var = str_replace(">", ">", $var);

$var = htmlspecialchars(strip_tags($var));

$var = nl2br($var);

return $var;

 

}

 

if (($_POST['nome']) && ($_POST['email']) && ($_POST['assunto']) && ($_POST['texto']))

{

 

$nome = dadoSeguro($_POST['nome']);

$email = dadoSeguro($_POST['email']);

$area = dadoSeguro($_POST['area']);

$assunto = dadoSeguro($_POST['assunto']);

$ref = dadoSeguro($_POST['ref']);

$texto = dadoSeguro($_POST['texto']);

 

 

$mensagem = "

<div align='center'><b>Contato ERICCOUTINHO.COM</b></div>

<p>

Nome: ".$nome."<br>

E-mail: ".$email."<br>

Área: ".$area."<br>

Assunto: ".$assunto."<br>

Referência: ".$ref."<br>

<br>

Texto: ".$texto."<br>

";

 

 

 

$mensagem .= "<p>-----<br>Mensagem enviada em: ". date("d/m/Y - H:i") ."<br>ERICCOUTINHO.COM (www.ericcoutinho.com)\n";

$remetente = $nome." <".$email.">";

$cabecalho = "Content-Type: text/html; charset=iso-8859-1\n";

$cabecalho .= "From: $remetente\n";

$envia = mail("email@ericcoutinho.com", "ERICCOUTINHO.COM - Contato do Site", $mensagem, $cabecalho);

if ($envia)

{

header("Location: enviado.htm");

exit;

} else {

header("Location: erro.htm");

exit;

}

} else {

header("Location: erro.htm");

exit;

}

 

?>

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.