Yii Swiftmailer

Can someone help me out here, been trying to do a fiel upload and attachment. I have this on my SiteController


{if(isset($_POST["submit"])){

if(!isset($_POST["first_name"]) 

	|| !isset($_POST["file"]))

 { 

 echo "MOO";

} else{

 $first_name = $_POST['first_name'];

$fileupload = $_POST['file'];


}

 $message = new YiiMailMessage;

 $message->setBody($first_name);

 $message->subject = 'My Subject';

 $message->addTo('my@domain.com');

 $message->from = Yii::app()->params['adminEmail'];





$message->attach(

Swift_Attachment::fromPath($_FILES['file']['tmp_name'])->setFilename($_FILES['file']['name'])

);




//$message->attach(Swift_Attachment::fromPath($fileupload)); -- This works

 Yii::app()->mail->send($message);

}


?>

My index


<form name="contactform" method="post">

 

  <label for="first_name">First Name *</label>

 

 <input type="submit" value="submit" name="submit" > 

 

  <input  type="text" name="first_name" maxlength="50" size="30">

  Attachment: <input type="file" name="file"> 


 </td>

I get Undefined index: file… Doesn’t $_FILES take everything from post action? Also the action is going to the Controller as the form variables are taken.

Thanks

replace


<form name="contactform" method="post">

by


<form name="contactform" method="post" enctype="multipart/form-data">

[color="#006400"]/* Moved from General Discussion to Extensions … */[/color]

Yh that’s done it, thanks mate. So simple yet I would have never figured it out.