help to find the error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
cris_300
Forum Newbie
Posts: 5
Joined: Thu May 21, 2009 10:40 am

help to find the error

Post by cris_300 »

hi again

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.";}   
?>
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: help to find the error

Post by Benjamin »

This question appears similar to your other post. You also didn't use

Code: Select all

tags.

Locked
Locked