Attachments aren't working.
Posted: Tue Aug 10, 2010 2:05 pm
I have a form that contains:
<div>If you have a recent picture of yourself, or perhaps a picture of your entire travel group attach it to your e-mail here.</div>
<td class="label" colspan="3" >Attachment (optional)
<input type="file" name="attachment" />
</td>
the file that handles it contains:
$file_path = $_FILES["attachment"]["tmp_name"];
$file_name = $_FILES["attachment"]["name"];
$file_type = $_FILES["attachment"]["type"];
and
$message = Swift_Message::newInstance();
//Create the attachment with your data
$attachment = Swift_Attachment::newInstance(($file_path), $file_name, $file_type);
//I also tried:
//$attachment = Swift_Attachment::newInstance($file_path, $file_name, $file_type);
//and
//$attachment = Swift_Attachment::newInstance("$file_path", "$file_name", "$file_type");
//and various other combos of quote marks.
//Attach it to the message
$message->attach($attachment);
But the attachments display an error when they are opened by the receiver. It says: "Loading meta information failed" The name of the file has been appended too. my_picture.jpg becomes my_picture.jpg_[ir4456].jpg which is the name of the file that is uploaded to the /tmp directory on the receivers end. The same thing happens with all image or pdf files.
Can anyone tell me why?
<div>If you have a recent picture of yourself, or perhaps a picture of your entire travel group attach it to your e-mail here.</div>
<td class="label" colspan="3" >Attachment (optional)
<input type="file" name="attachment" />
</td>
the file that handles it contains:
$file_path = $_FILES["attachment"]["tmp_name"];
$file_name = $_FILES["attachment"]["name"];
$file_type = $_FILES["attachment"]["type"];
and
$message = Swift_Message::newInstance();
//Create the attachment with your data
$attachment = Swift_Attachment::newInstance(($file_path), $file_name, $file_type);
//I also tried:
//$attachment = Swift_Attachment::newInstance($file_path, $file_name, $file_type);
//and
//$attachment = Swift_Attachment::newInstance("$file_path", "$file_name", "$file_type");
//and various other combos of quote marks.
//Attach it to the message
$message->attach($attachment);
But the attachments display an error when they are opened by the receiver. It says: "Loading meta information failed" The name of the file has been appended too. my_picture.jpg becomes my_picture.jpg_[ir4456].jpg which is the name of the file that is uploaded to the /tmp directory on the receivers end. The same thing happens with all image or pdf files.
Can anyone tell me why?