i modified the code
now is this i cut the funtion that validate the type of archive to attachment
but there is other problems
the explorer windows said that is the last line "?>"
buy i dont see it
if somebody tell me pleaseeeeeeeee help meeee
Code: Select all
<?
$max_allowed_file_size = "5000"; // this is size in KB
list($name_of_uploaded_file, $size_of_uploaded_file) = GetUploadedFileInfo();
if(!Validate($name_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size)) {
exit();
}
LoadUploadedFile($name_of_uploaded_file);
$path_of_uploaded_file = "uploads/" . $name_of_uploaded_file;
include_once('Mail.php');
include_once('mime.php');
ComposeMail($path_of_uploaded_file);
//////////////////// Functions ////////////////////////
function GetUploadedFileInfo() {
$file_info[] = basename($_FILES['uploaded_file']['name']);
$file_info[] = $_FILES["uploaded_file"]["size"]/1024;
return $file_info;
}
function Validate($name_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size) {
if($size_of_uploaded_file>$max_allowed_file_size ) {
echo " El tamano del archivo debe ser menor que" . $max_allowed_file_size . " KB. <a href='cotizacion.html'>Elija un archivo mas pequeno</a>";
return false;
}
function LoadUploadedFile($name_of_uploaded_file) {
move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "uploads/" . $name_of_uploaded_file);
return true;
}
function ComposeMail($name_of_uploaded_file) {
$name = $_POST['nombre'];
$user_message = $_POST['descripcion'];
$to = "cristina.arias.ing@gmail.com";
$subject="Una nueva solicitud fue realizada";
$from = $_POST['correo'];
$ubi = $_POST['Ubicacion'];
$tel = $_POST['telefono'];
$text = "A user " . $name ."Ubicado en:".$ubi."Telefono:".$tel. "Envio lo siguiente: " . $user_message;
$message = new Mail_mime();
$message->setTXTBody($text);
$message->addAttachment($name_of_uploaded_file);
$body = $message->get();
$extraheaders = array("From"=>$from, "Subject"=>$subject);
$headers = $message->headers($extraheaders);
$mail = Mail::factory("mail");
$mail->send($to, $headers, $body);
echo "Tu solicitud fue enviada exitosamente.";}
?>