Ver Mensaje Individual
  #6 (permalink)  
Antiguo 29/02/2008, 11:01
Avatar de jaronu
jaronu
 
Fecha de Ingreso: febrero-2008
Mensajes: 2.183
Antigüedad: 16 años, 2 meses
Puntos: 52
Re: adjuntar foto en un formulario

mira he encontrado esto en mi biblioteca de aplicaciones a ver si te lo puedes adaptar, primero has de subir la foto al server y despues que se envie el form


TRATA DE ADAPTARTELO


este es el codigo
Código PHP:
[<html>
<head>
<title>Subir un Archivo</title>
</head>
<body>
<?php
$subir_a 
"archivos/";

if (
$_POST['subir'])
{
if (@
move_uploaded_file($_FILES['archivo']['tmp_name'], $subir_a $_FILES['archivo']['name']))
{
echo 
"<span style="color#66CC00">&iexcl;El archivo <b><?=$_FILES['archivo']['name']</b> ha sido subido exitosamente!.</span>"
?>

<?php
} else {echo "<span style="color#FF0000">&iexcl;Ha habido un error al subir el archivo <b><?=$_FILES['archivo']['name']?></b></span>

<?php
}
}
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
<table border="0">
<tr>
<td><div align="right"><b>Archivo a subir:</b></div></td>
<td><input type="file" name="archivo"></td>
</tr>
<tr>
<td></td><td><div align="right"><input type="submit" name="subir" value="Subir Archivo"></div></td>
</tr>
</table>
</form>
</body>
</html> 


<?php  $semi_rand md5(time());
        
$mime_boundary "==Multipart_Boundary_x{"$semi_rand ."}x";

        
$headers "From: Ejemplo <[email protected]>\r\n";
        
$headers .= "MIME-Version: 1.0\r\n";
        
$headers .= "Content-type: multipart/mixed;\r\n";
        
$headers .= " boundary=\"{"$mime_boundary ."}\"";

            
$archivo "archivos/adjunto.jpg";

$cadenita explode('/',$archivo);
$cantidad count($cadenita);
$cantidad $cantidad 1;
$nombre_archivo $cadenita[$cantidad]; /* con esto obtengo el nombre del archivo */

            
$file fopen($archivo'rb');
            
$data fread($filefilesize($archivo));
            
fclose($file);
        
// Add a multipart boundary above the plain message
        
$MessageN "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" .
                    
"--{"$mime_boundary ."}\n" .
                    
"Content-Transfer-Encoding: 7bit\r\n\r\n"
                    
"MENSAJE\r\n";

          
// Base64 encode the file data
          
$data chunk_split(base64_encode($data));

          
// Add file attachment to the message
          
$MessageN .= "--{"$mime_boundary ."}\r\n" .
              
"Content-Type: {"filetype($archivo) ."};\r\n" .
              
" name=\""$nombre_archivo ."\"\r\n" .
              
"Content-Disposition: attachment;\r\n" .
              
" filename=\""$nombre_archivo ."\"\r\n" .
              
"Content-Transfer-Encoding: base64\r\n\r\n" .
              
$data "\r\n\r\n" .
              
"--{"$mime_boundary ."}--\r\n";  ?>
no se si te funcionara bien, pero esta es la idea