Jump to content


Lukaskaos

Member Since 30/01/2008
Offline Last Active 12/11/2011, 13:03
-----

Topics I've Started

Upload Arquivos Multiplos

12/02/2008, 23:13

Formulario: http://www.rockdasge...m/cadastro.html estou com problema upload das fotos, estou recebendo apenas uma foto.
Precesivo de ajuda para fazer esse upload funcionar corretamente.

envia.php
<?//pega os dados enviados pelo usuário$body = "Nome da Bandas:\t$banda\n";$body .= "Estilo:\t$estilo\n";$body .= "Cidade:\t$cidade\n";$body .= "Estado:\t$estado\n";$body .= "Integrantes:\t$integrantes\n";$body .= "vocal:\t$vocal1\n";$body .= "vocal:\t$vocal2\n";$body .= "guitarra:\t$guitarra1\n";$body .= "guitarra:\t$guitarra2\n";$body .= "baixo:\t$baixo1\n";$body .= "baixo:\t$baixo2\n";$body .= "baterista:\t$baterista\n";$body .= "Influencias:\t$influencias\n";$body .= "Inicio:\t$inicio\n";$body .= "sites:\t$sites\n";$body .= "orkut:\t$orkut\n";$body .= "youtube:\t$youtube\n";$body .= "myspace:\t$myspace\n";$body .= "purevolume:\t$purevolume\n";$body .= "outros:\t$outros\n";$body .= "contato:\t$contato\n";$body .= "email:\t$email\n";$nome        = $_POST["banda"];$to        = "contato@rockdasgerais.com";$from    = $_POST["contato"];$subject  = "cadastro de banda";$attach  = $_FILES["arquivo1"]["tmp_name"];$attach_name  = $_FILES["arquivo1"]["name"];$attach_size  = $_FILES["arquivo1"]["size"];$attach_type  = $_FILES["arquivo1"]["type"];$attach2  = $_FILES["arquivo2"]["tmp_name"];$attach2_name  = $_FILES["arquivo2"]["name"];$attach2_size  = $_FILES["arquivo2"]["size"];$attach2_type  = $_FILES["arquivo2"]["type"];$attach3  = $_FILES["arquivo3"]["tmp_name"];$attach3_name  = $_FILES["arquivo3"]["name"];$attach3_size  = $_FILES["arquivo3"]["size"];$attach3_type  = $_FILES["arquivo3"]["type"];$attach4  = $_FILES["arquivo4"]["tmp_name"];$attach4_name  = $_FILES["arquivo4"]["name"];$attach4_size  = $_FILES["arquivo4"]["size"];$attach4_type  = $_FILES["arquivo4"]["type"];//verifica se o email do destinatário é válidoif (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $to)){echo"<center>Digite um email valido</center>";echo "<center><a href=\"java script:history.go(-1)\">Voltar</center></a>";exit;}//define os headers de envio$mailheaders = "From: \"$nome\" <$from>\r\n";$mailheaders .= "Reply-To: $from\n";//e define a mensagem tirando barras para evitar problemas no script$msg_body = stripslashes($body);//verifica se tem arquivo anexo, o if é se tiver e o else se não tiver anexoif ($attach !=null){//abre o arquivo para codificá-lo no formato de email$file = fopen($attach, "r");$contents = fread($file, $attach_size);$encoded_attach = chunk_split(base64_encode($contents));fclose($file);//define os headers do anexo e da mensagem$mailheaders .= "MIME-version: 1.0\n";$mailheaders .= "Content-type: multipart/mixed; ";$mailheaders .= "boundary=\"Message-Boundary\"\n";$mailheaders .= "Content-transfer-encoding: 7BIT\n";$mailheaders .= "X-attachments: $attach_name";$body_top = "--Message-Boundary\n";$body_top .= "Content-type: text/plain; charset=US-ASCII\n";$body_top .= "Content-transfer-encoding: 7BIT\n";$body_top .= "Content-description: Mail message body\n\n";$msg_body = $body_top . $msg_body;$msg_body .= "\n\n--Message-Boundary\n";$msg_body .= "Content-type: $attach_type; name=\"$attach_name\"\n";$msg_body .= "Content-Transfer-Encoding: BASE64\n";$msg_body .= "Content-disposition: attachment; filename=\"$attach_name\"\n\n";$msg_body .= "$encoded_attach\n";$msg_body .= "--Message-Boundary--\n";//envia o email para as variáveis já definidas e tratadas e mostra mensagem de sucessomail($to, stripslashes($subject), $msg_body, $mailheaders);}else{//se não tiver anexo ele envia só a mensagem com esses headers$headers  = "MIME-Version: 1.0\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";$headers .= "From: \"$nome\" <$from>\r\n";mail($to, stripslashes($subject), $msg_body, $mailheaders);}?><font color="black" face="arial"size="4"><center><b>Enviado com sucesso!<br><a href="java script:window.close()">Fechar</a>

Upload De Arquivos

04/02/2008, 13:36

Perciso de ajuda para realizar upload de arquivos multiplos.
endereço do formulario http://www.rockdasge...m/cadastro.html
codigo envia.php

<?
//pega os dados enviados pelo usuário
$body = "Nome da Bandas:\t$banda\n";
$body .= "Estilo:\t$estilo\n";
$body .= "Cidade:\t$cidade\n";
$body .= "Estado:\t$estado\n";
$body .= "Integrantes:\t$integrantes\n";
$body .= "vocal:\t$vocal1\n";
$body .= "vocal:\t$vocal2\n";
$body .= "guitarra:\t$guitarra1\n";
$body .= "guitarra:\t$guitarra2\n";
$body .= "baixo:\t$baixo1\n";
$body .= "baixo:\t$baixo2\n";
$body .= "baterista:\t$baterista\n";
$body .= "Influencias:\t$influencias\n";
$body .= "Inicio:\t$inicio\n";
$body .= "sites:\t$sites\n";
$body .= "orkut:\t$orkut\n";
$body .= "youtube:\t$youtube\n";
$body .= "myspace:\t$myspace\n";
$body .= "purevolume:\t$purevolume\n";
$body .= "outros:\t$outros\n";
$body .= "contato:\t$contato\n";
$body .= "email:\t$email\n";


$nome = $_POST["banda"];
$to = "contato@rockdasgerais.com";
$from = $_POST["contato"];
$subject = "cadastro de banda";

$attach = $_FILES["arquivo1"]["tmp_name"];
$attach_name = $_FILES["arquivo1"]["name"];
$attach_size = $_FILES["arquivo1"]["size"];
$attach_type = $_FILES["arquivo1"]["type"];

$attach2 = $_FILES["arquivo2"]["tmp_name"];
$attach2_name = $_FILES["arquivo2"]["name"];
$attach2_size = $_FILES["arquivo2"]["size"];
$attach2_type = $_FILES["arquivo2"]["type"];

$attach3 = $_FILES["arquivo3"]["tmp_name"];
$attach3_name = $_FILES["arquivo3"]["name"];
$attach3_size = $_FILES["arquivo3"]["size"];
$attach3_type = $_FILES["arquivo3"]["type"];

$attach4 = $_FILES["arquivo4"]["tmp_name"];
$attach4_name = $_FILES["arquivo4"]["name"];
$attach4_size = $_FILES["arquivo4"]["size"];
$attach4_type = $_FILES["arquivo4"]["type"];



//verifica se o email do destinatário é válido
if (!ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $to)){

echo"<center>Digite um email valido</center>";
echo "<center><a href=\"java script:history.go(-1)\">Voltar</center></a>";
exit;

}

//define os headers de envio
$mailheaders = "From: \"$nome\" <$from>\r\n";
$mailheaders .= "Reply-To: $from\n";
//e define a mensagem tirando barras para evitar problemas no script
$msg_body = stripslashes($body);


//verifica se tem arquivo anexo, o if é se tiver e o else se não tiver anexo
if ($attach !=null)
{
//abre o arquivo para codificá-lo no formato de email
$file = fopen($attach, "r");
$contents = fread($file, $attach_size);
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
//define os headers do anexo e da mensagem
$mailheaders .= "MIME-version: 1.0\n";
$mailheaders .= "Content-type: multipart/mixed; ";
$mailheaders .= "boundary=\"Message-Boundary\"\n";
$mailheaders .= "Content-transfer-encoding: 7BIT\n";
$mailheaders .= "X-attachments: $attach_name";

$body_top = "--Message-Boundary\n";
$body_top .= "Content-type: text/plain; charset=US-ASCII\n";
$body_top .= "Content-transfer-encoding: 7BIT\n";
$body_top .= "Content-description: Mail message body\n\n";

$msg_body = $body_top . $msg_body;

$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-type: $attach_type; name=\"$attach_name\"\n";
$msg_body .= "Content-Transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$attach_name\"\n\n";
$msg_body .= "$encoded_attach\n";
$msg_body .= "--Message-Boundary--\n";
//envia o email para as variáveis já definidas e tratadas e mostra mensagem de sucesso
mail($to, stripslashes($subject), $msg_body, $mailheaders);
//echo"Enviado com Sucesso!";
//echo"<br>";
//echo"<a href=\"home.php\">Voltar para página Principal</a>";
}
else{
//se não tiver anexo ele envia só a mensagem com esses headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: \"$nome\" <$from>\r\n";

mail($to, stripslashes($subject), $msg_body, $mailheaders);
//echo"Enviado com Sucesso!";
//echo"<br>";
//echo"<a href=\"cadastro.html\">Voltar</a>";
}
?>
<font color="black" face="arial"size="4"><center><b>Enviado com sucesso!<br>
<a href="java script:window.close()">Fechar</a>

Desde de ja agradeço.

IPB Skin By Virteq