Olá pessoal, boa noite. Estou enfrentando alguns problema na criação de um formulário para enviar arquivos em anexo, seria um formulário focado apenas para envio de currículos. Abaixo irei colocar o código que montei, o formulário envia os dados como nome, email da pessoa, telefone, assunto, departamento, mensagem só não está enviando o arquivo anexado através do formulário. Se alguém puder colaborar com alguma ajuda. Segue o código: ================================================================================== <?
include("painel/conexao/conexao.php");
$curriculo=mysql_query("select * from curriculo order by id desc");
$ver_curriculo=mysql_fetch_array($curriculo);
$arquivo = $_FILES["arquivo"];
if($enviar=='sim') {
if($nome=='') {
echo "<script>window.location='index.php?pg=curriculo&erro=1';</script>";
}
if($email=='') {
echo "<script>window.location='index.php?pg=curriculo&erro=2';</script>";
}
if($telefone=='') {
echo "<script>window.location='index.php?pg=curriculo&erro=3';</script>";
}
if($assunto=='') {
echo "<script>window.location='index.php?pg=curriculo&erro=4';</script>";
}
$boundary = "XYZ-".date("dmYis")."-ZYX";
$fp = fopen($arquivo["tmp_name"], "rb");
$anexo = fread($fp, filesize($arquivo["tmp_name"]));
$anexo = base64_encode($anexo);
fclose($fp);
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "boundary=$boundary rn";
$headers .= "From: $nome <$email>\r\n";
$msg = "--$boundary n";
$msg .= "Content-Type: text/html; charset=iso-8859-1 n";
$msg .= "Content-Transfer-Encoding: 8bits nn";
$msg .= "<style type='text/css'>
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
}
.textoform {font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#006699; }
.resultadoform { font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; }
.textohistoria {font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; }
.style2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style4 {font-size: 12px}
.style5 {font-size: 16px; font-family: Arial, Helvetica, sans-serif;}
-->
</style>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='50' bgcolor='#D4D0C8' style='border-bottom:1px solid #666666;'><span class='style1'> Currículo enviado pelo site por $email<br>
</span></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right'><span class='textoform'>Nome</span>:</td>
<td width='92%' class='resultadoform'>$nome</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right'><span class='textoform'>Email</span>:</td>
<td width='92%' class='resultadoform'>$email</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' class='textoform'>Telefone::</td>
<td width='92%' class='resultadoform'>$telefone</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' class='textoform'>Assunto:</td>
<td width='92%' class='resultadoform'>$assunto</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' class='textoform'>Departamento:</td>
<td width='92%' class='resultadoform'>$departamento</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' valign='top' class='textoform'>Mensagem:</td>
<td width='92%' align='left' valign='top' class='resultadoform'>$mensagem</td>
</tr>
</table></td>
</tr>
<tr>
<td align='center'> </td>
</tr>
</table>
";
$msg .= "Content-Type: ".$arquivo["type"]."; name='".$arquivo['name']."' n";
$msg .= "Content-Transfer-Encoding: base64 n";
$msg .= "Content-Disposition: attachment; filename='".$arquivo['name']."' rn";
$msg .= "$anexo n";
$msg .= "--$boundary n";
mail("$departamento", 'Currículo Enviado pelo Site', $msg, $headers);
$headers .= "boundary=$boundary rn";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Portal ALT Brasil <rh@altbrasiltransportes.com.br>\r\n";
$msg = "--$boundary n";
$msg .= "Content-Type: text/html; charset=iso-8859-1 n";
$msg .= "Content-Transfer-Encoding: 8bits nn";
$msg .= "<style type='text/css'>
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
}
.textoform {font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#006699; }
.resultadoform { font-family:Arial, Helvetica, sans-serif; font-size:14px; font-weight:bold; }
.textohistoria {font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; }
.style2 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style4 {font-size: 12px}
.style5 {font-size: 16px; font-family: Arial, Helvetica, sans-serif;}
-->
</style>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td height='50' bgcolor='#D4D0C8' style='border-bottom:1px solid #666666;'><span class='style1'> Mensagem Automática.<br />
Por favor não responda.<br>
</span></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right'><span class='textoform'>Nome</span>:</td>
<td width='92%' class='resultadoform'>$nome</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right'><span class='textoform'>Email</span>:</td>
<td width='92%' class='resultadoform'>$email</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' class='textoform'>Telefone::</td>
<td width='92%' class='resultadoform'>$telefone</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' class='textoform'>Assunto:</td>
<td width='92%' class='resultadoform'>$assunto</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' class='textoform'>Departamento:</td>
<td width='92%' class='resultadoform'>$departamento</td>
</tr>
</table></td>
</tr>
<tr>
<td class='textoform'><table width='100%' border='0' cellspacing='2' cellpadding='2' style='border-bottom:1px solid #CCCCCC;'>
<tr>
<td width='8%' align='right' valign='top' class='textoform'>Mensagem:</td>
<td width='92%' align='left' valign='top' class='resultadoform'>$mensagem</td>
</tr>
</table></td>
</tr>
<tr>
<td align='center'> </td>
</tr>
<tr>
<td align='center'><span class='textoform'>Em breve estaremos entrando em contato.</span><br />
<span class='textohistoria'>Muito Obrigado !</span></td>
</tr>
</table>";
$msg .= "Content-Type: ".$arquivo["type"]."; name='".$arquivo['name']."' n";
$msg .= "Content-Transfer-Encoding: base64 n";
$msg .= "Content-Disposition: attachment; filename='".$arquivo['name']."' rn";
$msg .= "$anexo n";
$msg .= "--$boundary n";
mail("$email", 'Mensagem Automatica', $msg, $headers);
echo "<script>window.location='index.php?pg=curriculo&enviado=ok';</script>";
}
?>
<style type="text/css">
<!--
.vinhetahist {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
color: #FFFFFF;
}
.txt002 {
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#666666;
}
.formouvidoria {
border:1px solid #999999;
padding:1px;
}
.botoesform {
border:1px solid #008043;
background:#BEC8E3;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#FFFFFF;
padding:10px;
}
.errosite {
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#000000;
font-weight:bold;
}
.style1 {
font-size: 15px;
}
.style2 {
color: #FF0000;
}
.style4 {
color: #333333;
}
-->
</style>
<link rel="stylesheet" type="text/css" href="css/estilo_alt.css">
<table width="790" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" rowspan="5"> </td>
<td height="10"></td>
<td width="10" rowspan="5"> </td>
</tr>
<tr>
<td valign="top"><img src="imagens/contato.gif" width="468" height="59"></td>
</tr>
<tr>
<td height="8px" valign="top"></td>
</tr>
<tr>
<td height="250" valign="top" bgcolor="#FFFFFF"><span class="txtempresa">
<table width="100%" border="0" cellpadding="2" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr>
<td height="5"></td>
</tr>
<? if($erro==1) { ?>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="100%" align="center" valign="middle" bgcolor="#008043" class="errosite"><blink>Por favor preencha o " NOME "!</blink></td>
</tr>
</table></td>
</tr>
<? } ?>
<? if($erro==2) { ?>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="100%" align="center" valign="middle" bgcolor="#008043" class="errosite">Por favor preencha o " E-MAIL "!</td>
</tr>
</table></td>
</tr>
<? } ?>
<? if($erro==3) { ?>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="100%" align="center" valign="middle" bgcolor="#008043" class="errosite">Por favor preencha o " TELEFONE "!</td>
</tr>
</table></td>
</tr>
<? } ?>
<? if($erro==4) { ?>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="100%" align="center" valign="middle" bgcolor="#008043" class="errosite">Por favor preencha o " ASSUNTO "!</td>
</tr>
</table></td>
</tr>
<? } ?>
<? if($enviado=='ok') { ?>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="100%" align="center" valign="middle" bgcolor="#008043" class="errosite">Seu currículo foi enviado com sucesso !<br />
Em breve entraremos em contato !<br />
Muito Obrigado.</td>
</tr>
</table></td>
</tr>
<? } ?>
<tr>
<td>
<form action="index.php?pg=curriculo&enviar=sim" method="post" style="margin:auto;">
<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<td height="10" colspan="2"></td>
</tr>
<tr>
<td colspan="2" align="right" valign="middle" class="txt002"><div align="center" class="style4">Utilize o formulário abaixo para enviar seu currículo.</div></td>
</tr>
<tr>
<td colspan="2" align="right" valign="middle" class="txt002"><div align="center" class="style2">* <span class="style4">Campo Obrigatório</span></div></td>
</tr>
<tr>
<td height="15" colspan="2"></td>
</tr>
<tr>
<td width="28%" align="right" valign="middle" bgcolor="#FFFFFF" class="txt002"><span class="style2">* </span>Nome Completo:</td>
<td width="72%"><input name="nome" type="text" class="formouvidoria" id="nome" size="40" /></td>
</tr>
<tr>
<td align="right" valign="middle" class="txt002"><span class="style2">*</span> E-mail:</td>
<td><input name="email" type="text" class="formouvidoria" id="email" size="40" /></td>
</tr>
<tr>
<td align="right" valign="middle" class="txt002"><span class="style2">*</span>Telefone:</td>
<td><input name="telefone" type="text" class="formouvidoria" id="telefone" size="40" /></td>
</tr>
<tr>
<td align="right" valign="middle" class="txt002"><span class="style2">*</span> Assunto:</td>
<td><input name="assunto" type="text" class="formouvidoria" id="assunto" size="40" /></td>
</tr>
<tr>
<td align="right" valign="top" class="txt002"><span class="style2">*</span> Departamento:</td>
<td><label>
<select name="departamento" id="departamento">
<option>Cidade para atendimento. </option>
<? do { ?>
<option value="<? echo $ver_curriculo['email']; ?>"><? echo $ver_curriculo['nome']; ?></option>
<? }while($ver_curriculo=mysql_fetch_array($curriculo)); ?>
</select>
</label></td>
</tr>
<tr>
<td align="right" valign="top" class="txt002">Mensagem:</td>
<td><textarea name="mensagem" cols="32" rows="5" class="formouvidoria" id="mensagem"></textarea></td>
</tr>
<tr>
<td align="right" valign="middle" class="txt002"><span class="style2">*</span> Anexar CurrÍculo</td>
<td><input type="file" name="arquivo" id="arquivo"></td>
</tr>
<tr>
<td height="50" colspan="2" align="center" valign="middle" class="txt002"><label>
<input name="button" type="submit" class="botoesform" id="button" value="Enviar" />
</label>
<label>
<input name="button2" type="reset" class="botoesform" id="button2" value="Limpar" />
</label></td>
</tr>
</table>
</form> </td>
</tr>
</table>
</span></td>
</tr>
</table> ================================================================================= É um arquivo único, está usando banco de dados para buscar os departamentos cadastrado pelo painel. Acima a opção de envio está duplicada, para a pessoa que enviar o formulário, também irá receber o mesmo email que o departamento receberá. Obrigado.