Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

http://kevinnmurphy.com

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

Hack for Expression Engine for file attachments

// description of your code here

Hm- not out of the box.  There may be a plugin/extension floating around for it.  I’ve hacked it- was pretty easy.  The core email class already has the code you need for attaching files.  So you pretty much just have to modify the mod.email.php file- around 207 I changed the content type:
$data['enctype']                 = 'multipart/form-data';

Around 530 I added an array of uploaded files:
// hack for uploads
        $att = array();
        

        if (isset($_FILES) AND (count($_FILES) > 0))
        {
            $att_ret = $this->upload_file();
            foreach ($att_ret as $key=> $val)
            {
            $att[] = '/home/whatever/mail_attach/'.$val['name'];
            }
        }

Around 865 you need to tie the attached files to the email:
// hack for attachments
        if (count($att) > 0)
        {
        foreach($att as $val)
        {
                $email->attach($val);
        }
        }

After the emails are sent, I deleted the files:
// hack- delete the attached files from server
        
        if (isset($att) AND count($att) > 0)
        {
            foreach ($att as $val)
            {
                @unlink($val);
            }
        }

Then you need to add a function to handle the actual uploading- it’s easy because you can use the upload class- I think I modeled it after the file upload module because I needed to be able to upload multiple files.  Anyway- this part is a bit dangerous as you’re letting any idiot upload stuff.  So watch that you keep things as secure as possible- be sure everything is gettingscrubbed down’ and such. 

JavaScript Roll Overs

// JavaScript roll overs

<script type="text/javascript">

script>

// html code
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image1','','2.png',1)"><img src="1.png" name="Image1" width="155" height="71" border="0" id="Image1" />a>
« Newer Snippets
Older Snippets »
2 total  XML / RSS feed