Could not access file: Array and syntax error, unexpected '$ name' (T_VARIABLE) [closed]

2

I am using PHPMailer to send an email with attachment by a form, my code has no errors, but when I finish the form and press send, it returns an error but that the email was sent. Code:

   $name=$_REQUEST['name'];
   $email=$_REQUEST['email'];
   $message= $_REQUEST['message'];
   $message= "--$boundary" . PHP_EOL;
   $message= "Content-Type: text/html; charset='utf-8'" . PHP_EOL;
   $message= "--$boundary" . PHP_EOL;
   $tapete=$_REQUEST['tapete'];
   $medidas=$_REQUEST['medidas'];
   $cliente=$_REQUEST['cliente'];
   $mail = new PHPMailer();
   $mail->isSMTP();
   $mail->SMTPDebug = 2;
   $mail->Debugoutput = 'html';
   $mail->Host = 'smtp.gmail.com';
   $mail->Port = 587;
   $mail->SMTPSecure = 'tls';
   $mail->SMTPAuth = true;
   $mail->Username = "[email protected]";
   $mail->Password = "123Password";
   $mail->setFrom = ('[email protected]');
   $mail->Subject   = 'Formulário FacilityCom';
   $mail->Body      = 'Tipo e marca: $tapete \nMedidas: $medidas \nCliente: $cliente\n $from';
   $mail->AddAddress= ('[email protected]');
   $mail->IsHTML(true);
   $file_to_attach = $_FILES['file'];
   $filename=$_FILES['file'];
   $mail->AddAttachment($file_to_attach, $filename);
   $mail->Send();

The error I get is:

  

Parse error: syntax error, unexpected '$ name' (T_VARIABLE) in /home/u746419992/public_html/index.php on line 42

    
asked by anonymous 04.12.2015 / 15:08

2 answers

2

I think this:

 $mail->setFrom = ('[email protected]');

It should be this:

 $mail->setFrom('[email protected]');
    
06.12.2015 / 16:23
0

Mucap, this will happen even if you use a multiple in your input:file

If you have more than one file, the treatment will be different.

Often, your form looks like this:

<input name="file[]" type="file" />

Change to

<input name="file" type="file" />
    
04.12.2015 / 15:09